1 .\" $OpenBSD: ssh-keyscan.1,v 1.46 2022/06/03 04:00:15 dtucker Exp $
3 .\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
5 .\" Modification and redistribution in source and binary forms is
6 .\" permitted provided that due credit is given to the author and the
7 .\" OpenBSD project by leaving this copyright notice intact.
9 .Dd $Mdocdate: June 3 2022 $
14 .Nd gather SSH public keys from servers
22 .Op Ar host | addrlist namelist
25 is a utility for gathering the public SSH host keys of a number of
27 It was designed to aid in building and verifying
30 the format of which is documented in
33 provides a minimal interface suitable for use by shell and perl
37 uses non-blocking socket I/O to contact as many hosts as possible in
38 parallel, so it is very efficient.
39 The keys from a domain of 1,000
40 hosts can be collected in tens of seconds, even when some of those
41 hosts are down or do not run
43 For scanning, one does not need
44 login access to the machines that are being scanned, nor does the
45 scanning process involve any encryption.
47 The options are as follows:
52 to use IPv4 addresses only.
56 to use IPv6 addresses only.
58 Request certificates from target hosts instead of plain keys.
60 Print keys found as SSHFP DNS records.
61 The default is to print keys in a format usable as a
73 is supplied instead of a filename,
75 will read from the standard input.
76 Input is expected in the format:
78 1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4
81 Hash all hostnames and addresses in the output.
82 Hashed names may be used normally by
86 but they do not reveal identifying information should the file's contents
93 Set the timeout for connection attempts.
96 seconds have elapsed since a connection was initiated to a host or since the
97 last time anything was read from that host, the connection is
98 closed and the host in question considered unavailable.
99 The default is 5 seconds.
101 Specify the type of the key to fetch from the scanned hosts.
102 The possible values are
110 Multiple values may be specified by separating them with commas.
111 The default is to fetch
121 print debugging messages about progress.
124 If an ssh_known_hosts file is constructed using
126 without verifying the keys, users will be vulnerable to
127 .Em man in the middle
129 On the other hand, if the security model allows such a risk,
131 can help in the detection of tampered keyfiles or man in the middle
132 attacks which have begun after the ssh_known_hosts file was created.
134 .Pa /etc/ssh/ssh_known_hosts
136 Print the RSA host key for machine
139 .Dl $ ssh-keyscan -t rsa hostname
141 Find all hosts from the file
143 which have new or different keys from those in the sorted file
144 .Pa ssh_known_hosts :
145 .Bd -literal -offset indent
146 $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
147 sort -u - ssh_known_hosts | diff ssh_known_hosts -
155 .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
159 .An David Mazieres Aq Mt dm@lcs.mit.edu
160 wrote the initial version, and
161 .An Wayne Davison Aq Mt wayned@users.sourceforge.net
162 added support for protocol version 2.