1d95e11bfSDag-Erling Smørgrav.\" $OpenBSD: ssh-keyscan.1,v 1.17 2003/06/10 09:12:11 jmc Exp $ 21e8db6e2SBrian Feldman.\" 31e8db6e2SBrian Feldman.\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 41e8db6e2SBrian Feldman.\" 51e8db6e2SBrian Feldman.\" Modification and redistribution in source and binary forms is 61e8db6e2SBrian Feldman.\" permitted provided that due credit is given to the author and the 7ae1f160dSDag-Erling Smørgrav.\" OpenBSD project by leaving this copyright notice intact. 81e8db6e2SBrian Feldman.\" 91e8db6e2SBrian Feldman.Dd January 1, 1996 101e8db6e2SBrian Feldman.Dt SSH-KEYSCAN 1 111e8db6e2SBrian Feldman.Os 121e8db6e2SBrian Feldman.Sh NAME 131e8db6e2SBrian Feldman.Nm ssh-keyscan 141e8db6e2SBrian Feldman.Nd gather ssh public keys 151e8db6e2SBrian Feldman.Sh SYNOPSIS 161e8db6e2SBrian Feldman.Nm ssh-keyscan 17d0c8c0bcSDag-Erling Smørgrav.Bk -words 18ae1f160dSDag-Erling Smørgrav.Op Fl v46 19ae1f160dSDag-Erling Smørgrav.Op Fl p Ar port 20ae1f160dSDag-Erling Smørgrav.Op Fl T Ar timeout 21ae1f160dSDag-Erling Smørgrav.Op Fl t Ar type 22ae1f160dSDag-Erling Smørgrav.Op Fl f Ar file 23ae1f160dSDag-Erling Smørgrav.Op Ar host | addrlist namelist 24ae1f160dSDag-Erling Smørgrav.Op Ar ... 25d0c8c0bcSDag-Erling Smørgrav.Ek 261e8db6e2SBrian Feldman.Sh DESCRIPTION 271e8db6e2SBrian Feldman.Nm 281e8db6e2SBrian Feldmanis a utility for gathering the public ssh host keys of a number of 29d0c8c0bcSDag-Erling Smørgravhosts. 30d0c8c0bcSDag-Erling SmørgravIt was designed to aid in building and verifying 311e8db6e2SBrian Feldman.Pa ssh_known_hosts 321e8db6e2SBrian Feldmanfiles. 331e8db6e2SBrian Feldman.Nm 341e8db6e2SBrian Feldmanprovides a minimal interface suitable for use by shell and perl 351e8db6e2SBrian Feldmanscripts. 361e8db6e2SBrian Feldman.Pp 371e8db6e2SBrian Feldman.Nm 381e8db6e2SBrian Feldmanuses non-blocking socket I/O to contact as many hosts as possible in 39d0c8c0bcSDag-Erling Smørgravparallel, so it is very efficient. 40d0c8c0bcSDag-Erling SmørgravThe keys from a domain of 1,000 411e8db6e2SBrian Feldmanhosts can be collected in tens of seconds, even when some of those 42d0c8c0bcSDag-Erling Smørgravhosts are down or do not run ssh. 43d0c8c0bcSDag-Erling SmørgravFor scanning, one does not need 44ae1f160dSDag-Erling Smørgravlogin access to the machines that are being scanned, nor does the 45ae1f160dSDag-Erling Smørgravscanning process involve any encryption. 46ae1f160dSDag-Erling Smørgrav.Pp 47ae1f160dSDag-Erling SmørgravThe options are as follows: 481e8db6e2SBrian Feldman.Bl -tag -width Ds 49ae1f160dSDag-Erling Smørgrav.It Fl p Ar port 50ae1f160dSDag-Erling SmørgravPort to connect to on the remote host. 51ae1f160dSDag-Erling Smørgrav.It Fl T Ar timeout 52d0c8c0bcSDag-Erling SmørgravSet the timeout for connection attempts. 53d0c8c0bcSDag-Erling SmørgravIf 541e8db6e2SBrian Feldman.Pa timeout 551e8db6e2SBrian Feldmanseconds have elapsed since a connection was initiated to a host or since the 561e8db6e2SBrian Feldmanlast time anything was read from that host, then the connection is 57d0c8c0bcSDag-Erling Smørgravclosed and the host in question considered unavailable. 58d0c8c0bcSDag-Erling SmørgravDefault is 5 seconds. 59ae1f160dSDag-Erling Smørgrav.It Fl t Ar type 60ae1f160dSDag-Erling SmørgravSpecifies the type of the key to fetch from the scanned hosts. 61ae1f160dSDag-Erling SmørgravThe possible values are 62ae1f160dSDag-Erling Smørgrav.Dq rsa1 63ae1f160dSDag-Erling Smørgravfor protocol version 1 and 64ae1f160dSDag-Erling Smørgrav.Dq rsa 65ae1f160dSDag-Erling Smørgravor 66ae1f160dSDag-Erling Smørgrav.Dq dsa 67ae1f160dSDag-Erling Smørgravfor protocol version 2. 68ae1f160dSDag-Erling SmørgravMultiple values may be specified by separating them with commas. 69ae1f160dSDag-Erling SmørgravThe default is 70ae1f160dSDag-Erling Smørgrav.Dq rsa1 . 71ae1f160dSDag-Erling Smørgrav.It Fl f Ar filename 721e8db6e2SBrian FeldmanRead hosts or 731e8db6e2SBrian Feldman.Pa addrlist namelist 741e8db6e2SBrian Feldmanpairs from this file, one per line. 751e8db6e2SBrian FeldmanIf 761e8db6e2SBrian Feldman.Pa - 771e8db6e2SBrian Feldmanis supplied instead of a filename, 781e8db6e2SBrian Feldman.Nm 791e8db6e2SBrian Feldmanwill read hosts or 801e8db6e2SBrian Feldman.Pa addrlist namelist 811e8db6e2SBrian Feldmanpairs from the standard input. 82ae1f160dSDag-Erling Smørgrav.It Fl v 83ae1f160dSDag-Erling SmørgravVerbose mode. 84ae1f160dSDag-Erling SmørgravCauses 85ae1f160dSDag-Erling Smørgrav.Nm 86ae1f160dSDag-Erling Smørgravto print debugging messages about its progress. 87ae1f160dSDag-Erling Smørgrav.It Fl 4 88ae1f160dSDag-Erling SmørgravForces 89ae1f160dSDag-Erling Smørgrav.Nm 90ae1f160dSDag-Erling Smørgravto use IPv4 addresses only. 91ae1f160dSDag-Erling Smørgrav.It Fl 6 92ae1f160dSDag-Erling SmørgravForces 93ae1f160dSDag-Erling Smørgrav.Nm 94ae1f160dSDag-Erling Smørgravto use IPv6 addresses only. 951e8db6e2SBrian Feldman.El 96ae1f160dSDag-Erling Smørgrav.Sh SECURITY 97ae1f160dSDag-Erling SmørgravIf a ssh_known_hosts file is constructed using 98ae1f160dSDag-Erling Smørgrav.Nm 99ae1f160dSDag-Erling Smørgravwithout verifying the keys, users will be vulnerable to 100ae1f160dSDag-Erling Smørgrav.I man in the middle 101ae1f160dSDag-Erling Smørgravattacks. 102ae1f160dSDag-Erling SmørgravOn the other hand, if the security model allows such a risk, 103ae1f160dSDag-Erling Smørgrav.Nm 104ae1f160dSDag-Erling Smørgravcan help in the detection of tampered keyfiles or man in the middle 105ae1f160dSDag-Erling Smørgravattacks which have begun after the ssh_known_hosts file was created. 106ae1f160dSDag-Erling Smørgrav.Sh FILES 107ae1f160dSDag-Erling Smørgrav.Pa Input format: 108ae1f160dSDag-Erling Smørgrav.Bd -literal 109ae1f160dSDag-Erling Smørgrav1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4 1101e8db6e2SBrian Feldman.Ed 1111e8db6e2SBrian Feldman.Pp 112ae1f160dSDag-Erling Smørgrav.Pa Output format for rsa1 keys: 113ae1f160dSDag-Erling Smørgrav.Bd -literal 1141e8db6e2SBrian Feldmanhost-or-namelist bits exponent modulus 115ae1f160dSDag-Erling Smørgrav.Ed 1161e8db6e2SBrian Feldman.Pp 117ae1f160dSDag-Erling Smørgrav.Pa Output format for rsa and dsa keys: 118ae1f160dSDag-Erling Smørgrav.Bd -literal 119ae1f160dSDag-Erling Smørgravhost-or-namelist keytype base64-encoded-key 120ae1f160dSDag-Erling Smørgrav.Ed 121ae1f160dSDag-Erling Smørgrav.Pp 122ae1f160dSDag-Erling SmørgravWhere 123ae1f160dSDag-Erling Smørgrav.Pa keytype 124ae1f160dSDag-Erling Smørgravis either 125ae1f160dSDag-Erling Smørgrav.Dq ssh-rsa 126ae1f160dSDag-Erling Smørgravor 127d95e11bfSDag-Erling Smørgrav.Dq ssh-dss . 128ae1f160dSDag-Erling Smørgrav.Pp 129ae1f160dSDag-Erling Smørgrav.Pa /etc/ssh/ssh_known_hosts 130d95e11bfSDag-Erling Smørgrav.Sh EXAMPLES 131d95e11bfSDag-Erling SmørgravPrint the 132d95e11bfSDag-Erling Smørgrav.Pa rsa1 133d95e11bfSDag-Erling Smørgravhost key for machine 134d95e11bfSDag-Erling Smørgrav.Pa hostname : 135d95e11bfSDag-Erling Smørgrav.Bd -literal 136d95e11bfSDag-Erling Smørgrav$ ssh-keyscan hostname 137d95e11bfSDag-Erling Smørgrav.Ed 138d95e11bfSDag-Erling Smørgrav.Pp 139d95e11bfSDag-Erling SmørgravFind all hosts from the file 140d95e11bfSDag-Erling Smørgrav.Pa ssh_hosts 141d95e11bfSDag-Erling Smørgravwhich have new or different keys from those in the sorted file 142d95e11bfSDag-Erling Smørgrav.Pa ssh_known_hosts : 143d95e11bfSDag-Erling Smørgrav.Bd -literal 144d95e11bfSDag-Erling Smørgrav$ ssh-keyscan -t rsa,dsa -f ssh_hosts | \e 145d95e11bfSDag-Erling Smørgrav sort -u - ssh_known_hosts | diff ssh_known_hosts - 146d95e11bfSDag-Erling Smørgrav.Ed 147d95e11bfSDag-Erling Smørgrav.Sh SEE ALSO 148d95e11bfSDag-Erling Smørgrav.Xr ssh 1 , 149d95e11bfSDag-Erling Smørgrav.Xr sshd 8 150d95e11bfSDag-Erling Smørgrav.Sh AUTHORS 151d95e11bfSDag-Erling Smørgrav.An David Mazieres Aq dm@lcs.mit.edu 152d95e11bfSDag-Erling Smørgravwrote the initial version, and 153d95e11bfSDag-Erling Smørgrav.An Wayne Davison Aq wayned@users.sourceforge.net 154d95e11bfSDag-Erling Smørgravadded support for protocol version 2. 1551e8db6e2SBrian Feldman.Sh BUGS 1561e8db6e2SBrian FeldmanIt generates "Connection closed by remote host" messages on the consoles 157ae1f160dSDag-Erling Smørgravof all the machines it scans if the server is older than version 2.9. 1581e8db6e2SBrian FeldmanThis is because it opens a connection to the ssh port, reads the public 1591e8db6e2SBrian Feldmankey, and drops the connection as soon as it gets the key. 160