]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/ssh-keyscan.1
ssh: update comment text to match upstream
[FreeBSD/FreeBSD.git] / crypto / openssh / ssh-keyscan.1
1 .\"     $OpenBSD: ssh-keyscan.1,v 1.46 2022/06/03 04:00:15 dtucker Exp $
2 .\"
3 .\" Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 .\"
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.
8 .\"
9 .Dd $Mdocdate: June 3 2022 $
10 .Dt SSH-KEYSCAN 1
11 .Os
12 .Sh NAME
13 .Nm ssh-keyscan
14 .Nd gather SSH public keys from servers
15 .Sh SYNOPSIS
16 .Nm ssh-keyscan
17 .Op Fl 46cDHv
18 .Op Fl f Ar file
19 .Op Fl p Ar port
20 .Op Fl T Ar timeout
21 .Op Fl t Ar type
22 .Op Ar host | addrlist namelist
23 .Sh DESCRIPTION
24 .Nm
25 is a utility for gathering the public SSH host keys of a number of
26 hosts.
27 It was designed to aid in building and verifying
28 .Pa ssh_known_hosts
29 files,
30 the format of which is documented in
31 .Xr sshd 8 .
32 .Nm
33 provides a minimal interface suitable for use by shell and perl
34 scripts.
35 .Pp
36 .Nm
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
42 .Xr sshd 8 .
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.
46 .Pp
47 The options are as follows:
48 .Bl -tag -width Ds
49 .It Fl 4
50 Force
51 .Nm
52 to use IPv4 addresses only.
53 .It Fl 6
54 Force
55 .Nm
56 to use IPv6 addresses only.
57 .It Fl c
58 Request certificates from target hosts instead of plain keys.
59 .It Fl D
60 Print keys found as SSHFP DNS records.
61 The default is to print keys in a format usable as a
62 .Xr ssh 1
63 .Pa known_hosts
64 file.
65 .It Fl f Ar file
66 Read hosts or
67 .Dq addrlist namelist
68 pairs from
69 .Ar file ,
70 one per line.
71 If
72 .Sq -
73 is supplied instead of a filename,
74 .Nm
75 will read from the standard input.
76 Input is expected in the format:
77 .Bd -literal
78 1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4
79 .Ed
80 .It Fl H
81 Hash all hostnames and addresses in the output.
82 Hashed names may be used normally by
83 .Xr ssh 1
84 and
85 .Xr sshd 8 ,
86 but they do not reveal identifying information should the file's contents
87 be disclosed.
88 .It Fl p Ar port
89 Connect to
90 .Ar port
91 on the remote host.
92 .It Fl T Ar timeout
93 Set the timeout for connection attempts.
94 If
95 .Ar timeout
96 seconds have elapsed since a connection was initiated to a host or since the
97 last time anything was read from that host, the connection is
98 closed and the host in question considered unavailable.
99 The default is 5 seconds.
100 .It Fl t Ar type
101 Specify the type of the key to fetch from the scanned hosts.
102 The possible values are
103 .Dq dsa ,
104 .Dq ecdsa ,
105 .Dq ed25519 ,
106 .Dq ecdsa-sk ,
107 .Dq ed25519-sk ,
108 or
109 .Dq rsa .
110 Multiple values may be specified by separating them with commas.
111 The default is to fetch
112 .Dq rsa ,
113 .Dq ecdsa ,
114 .Dq ed25519 ,
115 .Dq ecdsa-sk ,
116 and
117 .Dq ed25519-sk
118 keys.
119 .It Fl v
120 Verbose mode:
121 print debugging messages about progress.
122 .El
123 .Pp
124 If an ssh_known_hosts file is constructed using
125 .Nm
126 without verifying the keys, users will be vulnerable to
127 .Em man in the middle
128 attacks.
129 On the other hand, if the security model allows such a risk,
130 .Nm
131 can help in the detection of tampered keyfiles or man in the middle
132 attacks which have begun after the ssh_known_hosts file was created.
133 .Sh FILES
134 .Pa /etc/ssh/ssh_known_hosts
135 .Sh EXAMPLES
136 Print the RSA host key for machine
137 .Ar hostname :
138 .Pp
139 .Dl $ ssh-keyscan -t rsa hostname
140 .Pp
141 Find all hosts from the file
142 .Pa ssh_hosts
143 which have new or different keys from those in the sorted file
144 .Pa ssh_known_hosts :
145 .Bd -literal -offset indent
146 $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
147         sort -u - ssh_known_hosts | diff ssh_known_hosts -
148 .Ed
149 .Sh SEE ALSO
150 .Xr ssh 1 ,
151 .Xr sshd 8
152 .Rs
153 .%D 2006
154 .%R RFC 4255
155 .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
156 .Re
157 .Sh AUTHORS
158 .An -nosplit
159 .An David Mazieres Aq Mt dm@lcs.mit.edu
160 wrote the initial version, and
161 .An Wayne Davison Aq Mt wayned@users.sourceforge.net
162 added support for protocol version 2.