Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 1 | SSH-KEYSCAN(1) General Commands Manual SSH-KEYSCAN(1) |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 2 | |
| 3 | NAME |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 4 | ssh-keyscan M-bM-^@M-^S gather ssh public keys |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 5 | |
| 6 | SYNOPSIS |
| 7 | ssh-keyscan [-46Hv] [-f file] [-p port] [-T timeout] [-t type] |
| 8 | [host | addrlist namelist] ... |
| 9 | |
| 10 | DESCRIPTION |
| 11 | ssh-keyscan is a utility for gathering the public ssh host keys of a |
| 12 | number of hosts. It was designed to aid in building and verifying |
| 13 | ssh_known_hosts files. ssh-keyscan provides a minimal interface suitable |
| 14 | for use by shell and perl scripts. |
| 15 | |
| 16 | ssh-keyscan uses non-blocking socket I/O to contact as many hosts as |
| 17 | possible in parallel, so it is very efficient. The keys from a domain of |
| 18 | 1,000 hosts can be collected in tens of seconds, even when some of those |
| 19 | hosts are down or do not run ssh. For scanning, one does not need login |
| 20 | access to the machines that are being scanned, nor does the scanning |
| 21 | process involve any encryption. |
| 22 | |
| 23 | The options are as follows: |
| 24 | |
| 25 | -4 Forces ssh-keyscan to use IPv4 addresses only. |
| 26 | |
| 27 | -6 Forces ssh-keyscan to use IPv6 addresses only. |
| 28 | |
| 29 | -f file |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 30 | Read hosts or M-bM-^@M-^\addrlist namelistM-bM-^@M-^] pairs from file, one per line. |
| 31 | If - is supplied instead of a filename, ssh-keyscan will read |
| 32 | hosts or M-bM-^@M-^\addrlist namelistM-bM-^@M-^] pairs from the standard input. |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 33 | |
| 34 | -H Hash all hostnames and addresses in the output. Hashed names may |
| 35 | be used normally by ssh and sshd, but they do not reveal |
| 36 | identifying information should the file's contents be disclosed. |
| 37 | |
| 38 | -p port |
| 39 | Port to connect to on the remote host. |
| 40 | |
| 41 | -T timeout |
| 42 | Set the timeout for connection attempts. If timeout seconds have |
| 43 | elapsed since a connection was initiated to a host or since the |
| 44 | last time anything was read from that host, then the connection |
| 45 | is closed and the host in question considered unavailable. |
| 46 | Default is 5 seconds. |
| 47 | |
| 48 | -t type |
| 49 | Specifies the type of the key to fetch from the scanned hosts. |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 50 | The possible values are M-bM-^@M-^\rsa1M-bM-^@M-^] for protocol version 1 and M-bM-^@M-^\dsaM-bM-^@M-^], |
| 51 | M-bM-^@M-^\ecdsaM-bM-^@M-^], M-bM-^@M-^\ed25519M-bM-^@M-^], or M-bM-^@M-^\rsaM-bM-^@M-^] for protocol version 2. Multiple |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 52 | values may be specified by separating them with commas. The |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 53 | default is to fetch M-bM-^@M-^\rsaM-bM-^@M-^], M-bM-^@M-^\ecdsaM-bM-^@M-^], and M-bM-^@M-^\ed25519M-bM-^@M-^] keys. |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 54 | |
| 55 | -v Verbose mode. Causes ssh-keyscan to print debugging messages |
| 56 | about its progress. |
| 57 | |
| 58 | SECURITY |
| 59 | If an ssh_known_hosts file is constructed using ssh-keyscan without |
| 60 | verifying the keys, users will be vulnerable to man in the middle |
| 61 | attacks. On the other hand, if the security model allows such a risk, |
| 62 | ssh-keyscan can help in the detection of tampered keyfiles or man in the |
| 63 | middle attacks which have begun after the ssh_known_hosts file was |
| 64 | created. |
| 65 | |
| 66 | FILES |
| 67 | Input format: |
| 68 | |
| 69 | 1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4 |
| 70 | |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 71 | Output format for RSA1 keys: |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 72 | |
| 73 | host-or-namelist bits exponent modulus |
| 74 | |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 75 | Output format for RSA, DSA, ECDSA, and Ed25519 keys: |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 76 | |
| 77 | host-or-namelist keytype base64-encoded-key |
| 78 | |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 79 | Where keytype is either M-bM-^@M-^\ecdsa-sha2-nistp256M-bM-^@M-^], M-bM-^@M-^\ecdsa-sha2-nistp384M-bM-^@M-^], |
| 80 | M-bM-^@M-^\ecdsa-sha2-nistp521M-bM-^@M-^], M-bM-^@M-^\ssh-ed25519M-bM-^@M-^], M-bM-^@M-^\ssh-dssM-bM-^@M-^] or M-bM-^@M-^\ssh-rsaM-bM-^@M-^]. |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 81 | |
| 82 | /etc/ssh/ssh_known_hosts |
| 83 | |
| 84 | EXAMPLES |
| 85 | Print the rsa host key for machine hostname: |
| 86 | |
| 87 | $ ssh-keyscan hostname |
| 88 | |
| 89 | Find all hosts from the file ssh_hosts which have new or different keys |
| 90 | from those in the sorted file ssh_known_hosts: |
| 91 | |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 92 | $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \ |
Greg Hartman | bd77cf7 | 2015-02-25 13:21:06 -0800 | [diff] [blame] | 93 | sort -u - ssh_known_hosts | diff ssh_known_hosts - |
| 94 | |
| 95 | SEE ALSO |
| 96 | ssh(1), sshd(8) |
| 97 | |
| 98 | AUTHORS |
| 99 | David Mazieres <dm@lcs.mit.edu> wrote the initial version, and Wayne |
| 100 | Davison <wayned@users.sourceforge.net> added support for protocol version |
| 101 | 2. |
| 102 | |
| 103 | BUGS |
| 104 | It generates "Connection closed by remote host" messages on the consoles |
| 105 | of all the machines it scans if the server is older than version 2.9. |
| 106 | This is because it opens a connection to the ssh port, reads the public |
| 107 | key, and drops the connection as soon as it gets the key. |
| 108 | |
Adam Langley | d059297 | 2015-03-30 14:49:51 -0700 | [diff] [blame] | 109 | OpenBSD 5.7 August 30, 2014 OpenBSD 5.7 |