1 .\" $OpenBSD: ssh-keyscan.1,v 1.49 2023/02/10 06:41:53 jmc 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: February 10 2023 $
14 .Nd gather SSH public keys from servers
23 .Op Ar host | addrlist namelist
26 is a utility for gathering the public SSH host keys of a number of
28 It was designed to aid in building and verifying
31 the format of which is documented in
34 provides a minimal interface suitable for use by shell and perl
38 uses non-blocking socket I/O to contact as many hosts as possible in
39 parallel, so it is very efficient.
40 The keys from a domain of 1,000
41 hosts can be collected in tens of seconds, even when some of those
42 hosts are down or do not run
44 For scanning, one does not need
45 login access to the machines that are being scanned, nor does the
46 scanning process involve any encryption.
48 Hosts to be scanned may be specified by hostname, address or by CIDR
49 network range (e.g. 192.168.16/28).
50 If a network range is specified, then all addresses in that range will
53 The options are as follows:
58 to use IPv4 addresses only.
62 to use IPv6 addresses only.
64 Request certificates from target hosts instead of plain keys.
66 Print keys found as SSHFP DNS records.
67 The default is to print keys in a format usable as a
79 is supplied instead of a filename,
81 will read from the standard input.
82 Names read from a file must start with an address, hostname or CIDR network
84 Addresses and hostnames may optionally be followed by comma-separated name
85 or address aliases that will be copied to the output.
91 10.0.0.1,sad.example.org
94 Hash all hostnames and addresses in the output.
95 Hashed names may be used normally by
99 but they do not reveal identifying information should the file's contents
102 Specify a key/value option.
103 At present, only a single option is supported:
105 .It Cm hashalg Ns = Ns Ar algorithm
106 Selects a hash algorithm to use when printing SSHFP records using the
113 The default is to print both.
120 Set the timeout for connection attempts.
123 seconds have elapsed since a connection was initiated to a host or since the
124 last time anything was read from that host, the connection is
125 closed and the host in question considered unavailable.
126 The default is 5 seconds.
128 Specify the type of the key to fetch from the scanned hosts.
129 The possible values are
137 Multiple values may be specified by separating them with commas.
138 The default is to fetch
148 print debugging messages about progress.
151 If an ssh_known_hosts file is constructed using
153 without verifying the keys, users will be vulnerable to
154 .Em man in the middle
156 On the other hand, if the security model allows such a risk,
158 can help in the detection of tampered keyfiles or man in the middle
159 attacks which have begun after the ssh_known_hosts file was created.
161 .Pa /etc/ssh/ssh_known_hosts
163 Print the RSA host key for machine
166 .Dl $ ssh-keyscan -t rsa hostname
168 Search a network range, printing all supported key types:
170 .Dl $ ssh-keyscan 192.168.0.64/25
172 Find all hosts from the file
174 which have new or different keys from those in the sorted file
175 .Pa ssh_known_hosts :
176 .Bd -literal -offset indent
177 $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
178 sort -u - ssh_known_hosts | diff ssh_known_hosts -
186 .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
190 .An David Mazieres Aq Mt dm@lcs.mit.edu
191 wrote the initial version, and
192 .An Wayne Davison Aq Mt wayned@users.sourceforge.net
193 added support for protocol version 2.