1 .\" $OpenBSD: ssh-keyscan.1,v 1.47 2022/10/28 02:29:34 djm 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: October 28 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 Hosts to be scanned may be specified by hostname, address or by CIDR
48 network range (e.g. 192.168.16/28).
49 If a network range is specified, then all addresses in that range will
52 The options are as follows:
57 to use IPv4 addresses only.
61 to use IPv6 addresses only.
63 Request certificates from target hosts instead of plain keys.
65 Print keys found as SSHFP DNS records.
66 The default is to print keys in a format usable as a
78 is supplied instead of a filename,
80 will read from the standard input.
81 Names read from a file must start with an address, hostname or CIDR network
83 Addresses and hostnames may optionally be followed by comma-separated name
84 or address aliases that will be copied to the output.
90 10.0.0.1,sad.example.org
93 Hash all hostnames and addresses in the output.
94 Hashed names may be used normally by
98 but they do not reveal identifying information should the file's contents
105 Set the timeout for connection attempts.
108 seconds have elapsed since a connection was initiated to a host or since the
109 last time anything was read from that host, the connection is
110 closed and the host in question considered unavailable.
111 The default is 5 seconds.
113 Specify the type of the key to fetch from the scanned hosts.
114 The possible values are
122 Multiple values may be specified by separating them with commas.
123 The default is to fetch
133 print debugging messages about progress.
136 If an ssh_known_hosts file is constructed using
138 without verifying the keys, users will be vulnerable to
139 .Em man in the middle
141 On the other hand, if the security model allows such a risk,
143 can help in the detection of tampered keyfiles or man in the middle
144 attacks which have begun after the ssh_known_hosts file was created.
146 .Pa /etc/ssh/ssh_known_hosts
148 Print the RSA host key for machine
151 .Dl $ ssh-keyscan -t rsa hostname
153 Search a network range, printing all supported key types:
155 .Dl $ ssh-keyscan 192.168.0.64/25
157 Find all hosts from the file
159 which have new or different keys from those in the sorted file
160 .Pa ssh_known_hosts :
161 .Bd -literal -offset indent
162 $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
163 sort -u - ssh_known_hosts | diff ssh_known_hosts -
171 .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
175 .An David Mazieres Aq Mt dm@lcs.mit.edu
176 wrote the initial version, and
177 .An Wayne Davison Aq Mt wayned@users.sourceforge.net
178 added support for protocol version 2.