1 .\" $OpenBSD: ssh-keyscan.1,v 1.52 2024/06/17 08:30:29 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: June 17 2024 $
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.
121 do not print server host name and banners in comments.
123 Set the timeout for connection attempts.
126 seconds have elapsed since a connection was initiated to a host or since the
127 last time anything was read from that host, the connection is
128 closed and the host in question considered unavailable.
129 The default is 5 seconds.
131 Specify the type of the key to fetch from the scanned hosts.
132 The possible values are
139 Multiple values may be specified by separating them with commas.
140 The default is to fetch all the above key types.
143 print debugging messages about progress.
146 If an ssh_known_hosts file is constructed using
148 without verifying the keys, users will be vulnerable to
149 .Em man in the middle
151 On the other hand, if the security model allows such a risk,
153 can help in the detection of tampered keyfiles or man in the middle
154 attacks which have begun after the ssh_known_hosts file was created.
156 .Pa /etc/ssh/ssh_known_hosts
158 Print the RSA host key for machine
161 .Dl $ ssh-keyscan -t rsa hostname
163 Search a network range, printing all supported key types:
165 .Dl $ ssh-keyscan 192.168.0.64/25
167 Find all hosts from the file
169 which have new or different keys from those in the sorted file
170 .Pa ssh_known_hosts :
171 .Bd -literal -offset indent
172 $ ssh-keyscan -t rsa,ecdsa,ed25519 -f ssh_hosts | \e
173 sort -u - ssh_known_hosts | diff ssh_known_hosts -
181 .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
185 .An David Mazieres Aq Mt dm@lcs.mit.edu
186 wrote the initial version, and
187 .An Wayne Davison Aq Mt wayned@users.sourceforge.net
188 added support for protocol version 2.