1SSH-KEYSCAN(1)            BSD General Commands Manual           SSH-KEYSCAN(1)
2

NAME

4     ssh-keyscan — gather SSH public keys from servers
5

SYNOPSIS

7     ssh-keyscan [-46cDHv] [-f file] [-p port] [-T timeout] [-t type]
8                 [host | addrlist namelist]
9

DESCRIPTION

11     ssh-keyscan is a utility for gathering the public SSH host keys of a num‐
12     ber of hosts.  It was designed to aid in building and verifying
13     ssh_known_hosts files, the format of which is documented in sshd(8).
14     ssh-keyscan provides a minimal interface suitable for use by shell and
15     perl scripts.
16
17     ssh-keyscan uses non-blocking socket I/O to contact as many hosts as pos‐
18     sible in parallel, so it is very efficient.  The keys from a domain of
19     1,000 hosts can be collected in tens of seconds, even when some of those
20     hosts are down or do not run sshd(8).  For scanning, one does not need
21     login access to the machines that are being scanned, nor does the scan‐
22     ning process involve any encryption.
23
24     The options are as follows:
25
26     -4      Force ssh-keyscan to use IPv4 addresses only.
27
28     -6      Force ssh-keyscan to use IPv6 addresses only.
29
30     -c      Request certificates from target hosts instead of plain keys.
31
32     -D      Print keys found as SSHFP DNS records.  The default is to print
33             keys in a format usable as a ssh(1) known_hosts file.
34
35     -f file
36             Read hosts or “addrlist namelist” pairs from file, one per line.
37             If ‘-’ is supplied instead of a filename, ssh-keyscan will read
38             from the standard input.  Input is expected in the format:
39
40             1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4
41
42     -H      Hash all hostnames and addresses in the output.  Hashed names may
43             be used normally by ssh(1) and sshd(8), but they do not reveal
44             identifying information should the file's contents be disclosed.
45
46     -p port
47             Connect to port on the remote host.
48
49     -T timeout
50             Set the timeout for connection attempts.  If timeout seconds have
51             elapsed since a connection was initiated to a host or since the
52             last time anything was read from that host, the connection is
53             closed and the host in question considered unavailable.  The
54             default is 5 seconds.
55
56     -t type
57             Specify the type of the key to fetch from the scanned hosts.  The
58             possible values are “dsa”, “ecdsa”, “ed25519”, or “rsa”.  Multi‐
59             ple values may be specified by separating them with commas.  The
60             default is to fetch “rsa”, “ecdsa”, and “ed25519” keys.
61
62     -v      Verbose mode: print debugging messages about progress.
63
64     If an ssh_known_hosts file is constructed using ssh-keyscan without veri‐
65     fying the keys, users will be vulnerable to man in the middle attacks.
66     On the other hand, if the security model allows such a risk, ssh-keyscan
67     can help in the detection of tampered keyfiles or man in the middle
68     attacks which have begun after the ssh_known_hosts file was created.
69

FILES

71     /etc/ssh/ssh_known_hosts
72

EXAMPLES

74     Print the RSA host key for machine hostname:
75
76           $ ssh-keyscan -t rsa hostname
77
78     Find all hosts from the file ssh_hosts which have new or different keys
79     from those in the sorted file ssh_known_hosts:
80
81           $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \
82                   sort -u - ssh_known_hosts | diff ssh_known_hosts -
83

SEE ALSO

85     ssh(1), sshd(8)
86
87     Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints, RFC
88     4255, 2006.
89

AUTHORS

91     David Mazieres <dm@lcs.mit.edu> wrote the initial version, and Wayne
92     Davison <wayned@users.sourceforge.net> added support for protocol version
93     2.
94
95BSD                              May 10, 2020                              BSD
Impressum