2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SSH-KEYSCAN 1 "Jul 24, 2004"
8 ssh-keyscan \- gather public ssh host keys of a number of hosts
12 \fBssh-keyscan\fR [\fB-v46\fR] [\fB-p\fR \fIport\fR] [\fB-T\fR \fItimeout\fR] [\fB-t\fR \fItype\fR]
13 [\fB-f\fR \fIfile\fR] [\fB-\fR] [\fIhost\fR... | \fIaddrlist\fR \fInamelist\fR] [...]
19 \fBssh-keyscan\fR is a utility for gathering the public ssh host keys of a
20 number of hosts. It was designed to aid in building and verifying
21 \fBssh_known_hosts\fR files. \fBssh-keyscan\fR provides a minimal interface
22 suitable for use by shell and perl scripts. The output of \fBssh-keyscan\fR is
23 directed to standard output.
26 \fBssh-keyscan\fR uses non-blocking socket I/O to contact as many hosts as
27 possible in parallel, so it is very efficient. The keys from a domain of 1,000
28 hosts can be collected in tens of seconds, even when some of those hosts are
29 down or do not run ssh. For scanning, one does not need login access to the
30 machines that are being scanned, nor does the scanning process involve any
40 \fIname.my.domain,name,n.my.domain,n,\fR1.2.3.4,1.2.4.4
47 Output format for \fBrsa1\fR keys:
51 \fIhost-or-namelist bits exponent modulus\fR
58 Output format for \fBrsa\fR and \fBdsa\fR keys, where \fIkeytype\fR is either
59 \fBssh-rsa\fR or `\fBssh-dsa\fR:
63 \fIhost-or-namelist keytype base64-encoded-key\fR
71 The following options are supported:
75 \fB\fB-f\fR \fIfilename\fR\fR
78 Read hosts or addrlist namelist pairs from this file, one per line. If you
79 specity - instead of a filename, \fBssh-keyscan\fR reads hosts or addrlist
80 namelist pairs from the standard input.
86 \fB\fB-p\fR \fIport\fR\fR
89 Port to connect to on the remote host.
95 \fB\fB-T\fR \fItimeout\fR\fR
98 Set the timeout for connection attempts. If \fItimeout\fR seconds have elapsed
99 since a connection was initiated to a host or since the last time anything was
100 read from that host, the connection is closed and the host in question is
101 considered unavailable. The default is for \fItimeout\fR is 5 seconds.
107 \fB\fB-t\fR \fItype\fR\fR
110 Specify the type of the key to fetch from the scanned hosts. The possible
111 values for \fItype\fR are \fBrsa1\fR for protocol version 1 and \fBrsa\fR or
112 \fBdsa\fR for protocol version 2. Specify multiple values by separating them
113 with commas. The default is \fBrsa1\fR.
122 Specify verbose mode. Print debugging messages about progress.
131 Force to use IPv4 addresses only.
140 Forces to use IPv6 addresses only.
146 If a \fBssh_known_hosts\fR file is constructed using \fBssh-keyscan\fR without
147 verifying the keys, users are vulnerable to man-in-the-middle attacks. If the
148 security model allows such a risk, \fBssh-keyscan\fR can help in the detection
149 of tampered keyfiles or man-in-the-middle attacks which have begun after the
150 \fBssh_known_hosts\fR file was created.
153 \fBExample 1 \fRPrinting the \fBrsa1\fR Host Key
156 The following example prints the \fBrsa1\fR host key for machine
162 $ ssh-keyscan hostname
168 \fBExample 2 \fRFinding All Hosts
171 The following commands finds all hosts from the file \fBssh_hosts\fR which have
172 new or different keys from those in the sorted file \fBssh_known_hosts\fR:
177 $ ssh-keyscan -t rsa,dsa -f ssh_hosts | \e
178 sort -u - ssh_known_hosts | diff ssh_known_hosts -
187 \fB\fB/etc/ssh_known_hosts\fR \fR
196 The following exit values are returned:
203 No usage errors. \fBssh-keyscan\fR might or might not have succeeded or failed
204 to scan one, more or all of the given hosts.
219 See \fBattributes\fR(5) for descriptions of the following attributes:
227 ATTRIBUTE TYPE ATTRIBUTE VALUE
229 Interface Stability Evolving
235 \fBssh\fR(1), \fBsshd\fR(1M), \fBattributes\fR(5)
239 David Mazieres wrote the initial version, and Wayne Davison added suppport for
244 \fBssh\(emkeyscan\fR generates
248 Connection closed by remote host
255 messages on the consoles of all machines it scans if the server is older than
256 version 2.9. This is because \fBssh-keyscan\fR opens a connection to the
257 \fBssh\fR port, reads the public key, and drops the connection as soon as it