blob: 17f73406e750569c01c6f605d42ab70acfc9cb1e [file] [log] [blame]
Ben Lindstrom594e2032001-09-12 18:35:30 +00001.\" $OpenBSD: ssh-keyscan.1,v 1.12 2001/09/05 06:23:07 deraadt Exp $
Ben Lindstromb22c2b82001-03-05 06:50:47 +00002.\"
3.\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4.\"
5.\" Modification and redistribution in source and binary forms is
6.\" permitted provided that due credit is given to the author and the
Ben Lindstroma238f6e2001-06-09 01:30:39 +00007.\" OpenBSD project by leaving this copyright notice intact.
Ben Lindstrom36579d32001-01-29 07:39:26 +00008.\"
Ben Lindstromb6434ae2000-12-05 01:15:09 +00009.Dd January 1, 1996
Ben Lindstromb22c2b82001-03-05 06:50:47 +000010.Dt SSH-KEYSCAN 1
Ben Lindstromb6434ae2000-12-05 01:15:09 +000011.Os
12.Sh NAME
13.Nm ssh-keyscan
14.Nd gather ssh public keys
15.Sh SYNOPSIS
16.Nm ssh-keyscan
Ben Lindstrom325e70c2001-08-06 22:41:30 +000017.Op Fl v46
18.Op Fl p Ar port
19.Op Fl T Ar timeout
20.Op Fl t Ar type
21.Op Fl f Ar file
22.Op Ar host | addrlist namelist
23.Op Ar ...
Ben Lindstromb6434ae2000-12-05 01:15:09 +000024.Sh DESCRIPTION
25.Nm
26is a utility for gathering the public ssh host keys of a number of
27hosts. It was designed to aid in building and verifying
28.Pa ssh_known_hosts
29files.
30.Nm
31provides a minimal interface suitable for use by shell and perl
32scripts.
33.Pp
34.Nm
35uses non-blocking socket I/O to contact as many hosts as possible in
36parallel, so it is very efficient. The keys from a domain of 1,000
37hosts can be collected in tens of seconds, even when some of those
Ben Lindstrom594e2032001-09-12 18:35:30 +000038hosts are down or do not run ssh. For scanning, one does not need
39login access to the machines that are being scanned, nor does the
40scanning process involve any encryption.
Ben Lindstrom0b5afb92001-08-06 22:01:29 +000041.Pp
42The options are as follows:
Ben Lindstromb6434ae2000-12-05 01:15:09 +000043.Bl -tag -width Ds
Ben Lindstrom325e70c2001-08-06 22:41:30 +000044.It Fl p Ar port
45Port to connect to on the remote host.
Ben Lindstrom8d066fb2001-09-12 17:06:13 +000046.It Fl T Ar timeout
Ben Lindstrom24643222001-06-25 05:08:11 +000047Set the timeout for connection attempts. If
Ben Lindstromb6434ae2000-12-05 01:15:09 +000048.Pa timeout
49seconds have elapsed since a connection was initiated to a host or since the
50last time anything was read from that host, then the connection is
51closed and the host in question considered unavailable. Default is 5
52seconds.
Ben Lindstrom325e70c2001-08-06 22:41:30 +000053.It Fl t Ar type
Ben Lindstrom8d066fb2001-09-12 17:06:13 +000054Specifies the type of the key to fetch from the scanned hosts.
Ben Lindstrom325e70c2001-08-06 22:41:30 +000055The possible values are
56.Dq rsa1
57for protocol version 1 and
58.Dq rsa
59or
60.Dq dsa
61for protocol version 2.
62Multiple values may be specified by separating them with commas.
63The default is
64.Dq rsa1 .
65.It Fl f Ar filename
Ben Lindstrom24643222001-06-25 05:08:11 +000066Read hosts or
Ben Lindstromb6434ae2000-12-05 01:15:09 +000067.Pa addrlist namelist
68pairs from this file, one per line.
69If
70.Pa -
71is supplied instead of a filename,
72.Nm
Ben Lindstrom24643222001-06-25 05:08:11 +000073will read hosts or
Ben Lindstromb6434ae2000-12-05 01:15:09 +000074.Pa addrlist namelist
75pairs from the standard input.
Ben Lindstrom325e70c2001-08-06 22:41:30 +000076.It Fl v
77Verbose mode.
78Causes
79.Nm
80to print debugging messages about its progress.
81.It Fl 4
82Forces
83.Nm
84to use IPv4 addresses only.
85.It Fl 6
86Forces
87.Nm
88to use IPv6 addresses only.
Ben Lindstromd26dcf32001-01-06 15:18:16 +000089.El
Ben Lindstrom0b5afb92001-08-06 22:01:29 +000090.Sh SECURITY
Ben Lindstrom594e2032001-09-12 18:35:30 +000091If a ssh_known_hosts file is constructed using
Ben Lindstrom0b5afb92001-08-06 22:01:29 +000092.Nm
Ben Lindstrom594e2032001-09-12 18:35:30 +000093without verifying the keys, users will be vulnerable to
Ben Lindstrom0b5afb92001-08-06 22:01:29 +000094.I man in the middle
95attacks.
Ben Lindstrom594e2032001-09-12 18:35:30 +000096On the other hand, if the security model allows such a risk,
Ben Lindstrom0b5afb92001-08-06 22:01:29 +000097.Nm
Ben Lindstrom594e2032001-09-12 18:35:30 +000098can help in the detection of tampered keyfiles or man in the middle
99attacks which have begun after the ssh_known_hosts file was created.
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000100.Sh EXAMPLES
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000101.Pp
102Print the
103.Pa rsa1
104host key for machine
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000105.Pa hostname :
106.Bd -literal
107ssh-keyscan hostname
108.Ed
109.Pp
110Find all hosts from the file
111.Pa ssh_hosts
112which have new or different keys from those in the sorted file
113.Pa ssh_known_hosts :
114.Bd -literal
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000115ssh-keyscan -t rsa,dsa -f ssh_hosts | \e\
116 sort -u - ssh_known_hosts | diff ssh_known_hosts -
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000117.Ed
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000118.Sh FILES
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000119.Pa Input format:
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000120.Bd -literal
Ben Lindstromb6434ae2000-12-05 01:15:09 +00001211.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000122.Ed
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000123.Pp
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000124.Pa Output format for rsa1 keys:
125.Bd -literal
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000126host-or-namelist bits exponent modulus
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000127.Ed
128.Pp
129.Pa Output format for rsa and dsa keys:
130.Bd -literal
131host-or-namelist keytype base64-encoded-key
132.Ed
133.Pp
134Where
135.Pa keytype
136is either
137.Dq ssh-rsa
138or
139.Dq ssh-dsa .
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000140.Pp
141.Pa /etc/ssh_known_hosts
142.Sh BUGS
143It generates "Connection closed by remote host" messages on the consoles
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000144of all the machines it scans if the server is older than version 2.9.
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000145This is because it opens a connection to the ssh port, reads the public
146key, and drops the connection as soon as it gets the key.
147.Sh SEE ALSO
Ben Lindstromb22c2b82001-03-05 06:50:47 +0000148.Xr ssh 1 ,
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000149.Xr sshd 8
Ben Lindstromd2bf0d62001-06-25 04:10:54 +0000150.Sh AUTHORS
Ben Lindstromb6434ae2000-12-05 01:15:09 +0000151David Mazieres <dm@lcs.mit.edu>
Ben Lindstrom325e70c2001-08-06 22:41:30 +0000152wrote the initial version, and
153Wayne Davison <wayned@users.sourceforge.net>
154added support for protocol version 2.