summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/ssh-keyscan.1
blob: 6cda7c0a7a76e17079e59d8c284b72cd356b2e7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH ssh-keyscan 1 "24 Jul 2004" "SunOS 5.11" "User Commands"
.SH NAME
ssh-keyscan \- gather public ssh host keys of a number of hosts
.SH SYNOPSIS
.LP
.nf
\fBssh-keyscan\fR [\fB-v46\fR] [\fB-p\fR \fIport\fR] [\fB-T\fR \fItimeout\fR] [\fB-t\fR \fItype\fR] 
     [\fB-f\fR \fIfile\fR] [\fB-\fR] [\fIhost\fR... | \fIaddrlist\fR \fInamelist\fR] [...]
.fi

.SH DESCRIPTION
.sp
.LP
\fBssh-keyscan\fR is a utility for gathering the public ssh host keys of a
number of hosts. It was designed to aid in building and verifying
\fBssh_known_hosts\fR files. \fBssh-keyscan\fR provides a minimal interface
suitable for use by shell and perl scripts. The output of \fBssh-keyscan\fR is
directed to standard output.
.sp
.LP
\fBssh-keyscan\fR uses non-blocking socket I/O to contact as many hosts as
possible in parallel, so it is very efficient. The keys from a domain of 1,000
hosts can be collected in tens of seconds, even when some of those hosts are
down or do not run ssh. For scanning, one does not need login access to the
machines that are being scanned, nor does the scanning process involve any
encryption.
.SS "File Format"
.sp
.LP
Input format:
.sp
.in +2
.nf
1.2.3.4,1.2.4.4
\fIname.my.domain,name,n.my.domain,n,\fR1.2.3.4,1.2.4.4
.fi
.in -2
.sp

.sp
.LP
Output format for \fBrsa1\fR keys:
.sp
.in +2
.nf
\fIhost-or-namelist bits exponent modulus\fR
.fi
.in -2
.sp

.sp
.LP
Output format for \fBrsa\fR and \fBdsa\fR keys, where \fIkeytype\fR is either
\fBssh-rsa\fR or `\fBssh-dsa\fR:
.sp
.in +2
.nf
\fIhost-or-namelist keytype base64-encoded-key\fR
.fi
.in -2
.sp

.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.mk
.na
\fB\fB-f\fR \fIfilename\fR\fR
.ad
.RS 28n
.rt  
Read hosts or addrlist namelist pairs from this file, one per line. If you
specity - instead of a filename, \fBssh-keyscan\fR reads hosts or addrlist
namelist pairs from the standard input.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-p\fR \fIport\fR\fR
.ad
.RS 28n
.rt  
Port to connect to on the remote host.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-T\fR \fItimeout\fR\fR
.ad
.RS 28n
.rt  
Set the timeout for connection attempts. If \fItimeout\fR seconds have elapsed
since a connection was initiated to a host or since the last time anything was
read from that host, the connection is closed and the host in question is
considered unavailable. The default is for \fItimeout\fR is 5 seconds.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-t\fR \fItype\fR\fR
.ad
.RS 28n
.rt  
Specify the type of the key to fetch from the scanned hosts. The possible
values for \fItype\fR are \fBrsa1\fR for protocol version 1 and \fBrsa\fR or
\fBdsa\fR for protocol version 2. Specify multiple values by separating them
with commas. The default is \fBrsa1\fR.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-v\fR\fR
.ad
.RS 28n
.rt  
Specify verbose mode. Print debugging messages about progress.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-4\fR\fR
.ad
.RS 28n
.rt  
Force to use IPv4 addresses only.
.RE

.sp
.ne 2
.mk
.na
\fB\fB-6\fR\fR
.ad
.RS 28n
.rt  
Forces to use IPv6 addresses only.
.RE

.SH SECURITY
.sp
.LP
If a \fBssh_known_hosts\fR file is constructed using \fBssh-keyscan\fR without
verifying the keys, users are vulnerable to man-in-the-middle attacks. If the
security model allows such a risk, \fBssh-keyscan\fR can help in the detection
of tampered keyfiles or man-in-the-middle attacks which have begun after the
\fBssh_known_hosts\fR file was created.
.SH EXAMPLES
.LP
\fBExample 1 \fRPrinting the \fBrsa1\fR Host Key
.sp
.LP
The following example prints the \fBrsa1\fR host key for machine
\fBhostname\fR:

.sp
.in +2
.nf
$ ssh-keyscan hostname
.fi
.in -2
.sp

.LP
\fBExample 2 \fRFinding All Hosts
.sp
.LP
The following commands finds all hosts from the file \fBssh_hosts\fR which have
new or different keys from those in the sorted file \fBssh_known_hosts\fR:

.sp
.in +2
.nf
$ ssh-keyscan -t rsa,dsa -f ssh_hosts | \e
     sort -u - ssh_known_hosts | diff ssh_known_hosts -
.fi
.in -2
.sp

.SH FILES
.sp
.ne 2
.mk
.na
\fB\fB/etc/ssh_known_hosts\fR \fR
.ad
.RS 25n
.rt  

.RE

.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.mk
.na
\fB\fB0\fR \fR
.ad
.RS 6n
.rt  
No usage errors. \fBssh-keyscan\fR might or might not have succeeded or failed
to scan one, more or all of the given hosts.
.RE

.sp
.ne 2
.mk
.na
\fB\fB1\fR\fR
.ad
.RS 6n
.rt  
Usage error.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
tab() box;
cw(2.75i) |cw(2.75i) 
lw(2.75i) |lw(2.75i) 
.
ATTRIBUTE TYPEATTRIBUTE VALUE
_
Interface StabilityEvolving
.TE

.SH SEE ALSO
.sp
.LP
\fBssh\fR(1), \fBsshd\fR(1M), \fBattributes\fR(5)
.SH AUTHORS
.sp
.LP
David Mazieres wrote the initial version, and Wayne Davison added suppport for
protocol version 2.
.SH BUGS
.sp
.LP
\fBssh\(emkeyscan\fR generates
.sp
.in +2
.nf
Connection closed by remote host
.fi
.in -2
.sp

.sp
.LP
messages on the consoles of all machines it scans if the server is older than
version 2.9. This is because \fBssh-keyscan\fR opens a connection to the
\fBssh\fR port, reads the public key, and drops the connection as soon as it
gets the key.