xref: /freebsd/crypto/openssh/ssh-keyscan.1 (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1.\"	$OpenBSD: ssh-keyscan.1,v 1.44 2018/03/05 07:03:18 jmc 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: March 5 2018 $
10.Dt SSH-KEYSCAN 1
11.Os
12.Sh NAME
13.Nm ssh-keyscan
14.Nd gather SSH public keys
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
25is a utility for gathering the public SSH host keys of a number of
26hosts.
27It was designed to aid in building and verifying
28.Pa ssh_known_hosts
29files,
30the format of which is documented in
31.Xr sshd 8 .
32.Nm
33provides a minimal interface suitable for use by shell and perl
34scripts.
35.Pp
36.Nm
37uses non-blocking socket I/O to contact as many hosts as possible in
38parallel, so it is very efficient.
39The keys from a domain of 1,000
40hosts can be collected in tens of seconds, even when some of those
41hosts are down or do not run
42.Xr sshd 8 .
43For scanning, one does not need
44login access to the machines that are being scanned, nor does the
45scanning process involve any encryption.
46.Pp
47The options are as follows:
48.Bl -tag -width Ds
49.It Fl 4
50Force
51.Nm
52to use IPv4 addresses only.
53.It Fl 6
54Force
55.Nm
56to use IPv6 addresses only.
57.It Fl c
58Request certificates from target hosts instead of plain keys.
59.It Fl D
60Print keys found as SSHFP DNS records.
61The default is to print keys in a format usable as a
62.Xr ssh 1
63.Pa known_hosts
64file.
65.It Fl f Ar file
66Read hosts or
67.Dq addrlist namelist
68pairs from
69.Ar file ,
70one per line.
71If
72.Sq -
73is supplied instead of a filename,
74.Nm
75will read from the standard input.
76Input is expected in the format:
77.Bd -literal
781.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
81Hash all hostnames and addresses in the output.
82Hashed names may be used normally by
83.Xr ssh 1
84and
85.Xr sshd 8 ,
86but they do not reveal identifying information should the file's contents
87be disclosed.
88.It Fl p Ar port
89Connect to
90.Ar port
91on the remote host.
92.It Fl T Ar timeout
93Set the timeout for connection attempts.
94If
95.Ar timeout
96seconds have elapsed since a connection was initiated to a host or since the
97last time anything was read from that host, the connection is
98closed and the host in question considered unavailable.
99The default is 5 seconds.
100.It Fl t Ar type
101Specify the type of the key to fetch from the scanned hosts.
102The possible values are
103.Dq dsa ,
104.Dq ecdsa ,
105.Dq ed25519 ,
106or
107.Dq rsa .
108Multiple values may be specified by separating them with commas.
109The default is to fetch
110.Dq rsa ,
111.Dq ecdsa ,
112and
113.Dq ed25519
114keys.
115.It Fl v
116Verbose mode:
117print debugging messages about progress.
118.El
119.Pp
120If an ssh_known_hosts file is constructed using
121.Nm
122without verifying the keys, users will be vulnerable to
123.Em man in the middle
124attacks.
125On the other hand, if the security model allows such a risk,
126.Nm
127can help in the detection of tampered keyfiles or man in the middle
128attacks which have begun after the ssh_known_hosts file was created.
129.Sh FILES
130.Pa /etc/ssh/ssh_known_hosts
131.Sh EXAMPLES
132Print the RSA host key for machine
133.Ar hostname :
134.Pp
135.Dl $ ssh-keyscan -t rsa hostname
136.Pp
137Find all hosts from the file
138.Pa ssh_hosts
139which have new or different keys from those in the sorted file
140.Pa ssh_known_hosts :
141.Bd -literal -offset indent
142$ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
143	sort -u - ssh_known_hosts | diff ssh_known_hosts -
144.Ed
145.Sh SEE ALSO
146.Xr ssh 1 ,
147.Xr sshd 8
148.Rs
149.%D 2006
150.%R RFC 4255
151.%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
152.Re
153.Sh AUTHORS
154.An -nosplit
155.An David Mazieres Aq Mt dm@lcs.mit.edu
156wrote the initial version, and
157.An Wayne Davison Aq Mt wayned@users.sourceforge.net
158added support for protocol version 2.
159