Annotation of src/usr.bin/ssh/ssh-keyscan.1, Revision 1.46
1.46 ! dtucker 1: .\" $OpenBSD: ssh-keyscan.1,v 1.45 2019/11/30 07:07:59 jmc Exp $
1.4 deraadt 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
1.6 pvalchev 7: .\" OpenBSD project by leaving this copyright notice intact.
1.3 niklas 8: .\"
1.46 ! dtucker 9: .Dd $Mdocdate: November 30 2019 $
1.4 deraadt 10: .Dt SSH-KEYSCAN 1
1.1 markus 11: .Os
12: .Sh NAME
13: .Nm ssh-keyscan
1.45 jmc 14: .Nd gather SSH public keys from servers
1.1 markus 15: .Sh SYNOPSIS
16: .Nm ssh-keyscan
1.41 djm 17: .Op Fl 46cDHv
1.20 jmc 18: .Op Fl f Ar file
1.10 markus 19: .Op Fl p Ar port
20: .Op Fl T Ar timeout
21: .Op Fl t Ar type
22: .Op Ar host | addrlist namelist
1.1 markus 23: .Sh DESCRIPTION
24: .Nm
1.43 jmc 25: is a utility for gathering the public SSH host keys of a number of
1.15 jmc 26: hosts.
27: It was designed to aid in building and verifying
1.1 markus 28: .Pa ssh_known_hosts
1.44 jmc 29: files,
30: the format of which is documented in
31: .Xr sshd 8 .
1.1 markus 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
1.15 jmc 38: parallel, so it is very efficient.
39: The keys from a domain of 1,000
1.1 markus 40: hosts can be collected in tens of seconds, even when some of those
1.43 jmc 41: hosts are down or do not run
42: .Xr sshd 8 .
1.15 jmc 43: For scanning, one does not need
1.12 deraadt 44: login access to the machines that are being scanned, nor does the
45: scanning process involve any encryption.
1.9 mpech 46: .Pp
47: The options are as follows:
1.1 markus 48: .Bl -tag -width Ds
1.20 jmc 49: .It Fl 4
1.43 jmc 50: Force
1.20 jmc 51: .Nm
52: to use IPv4 addresses only.
53: .It Fl 6
1.43 jmc 54: Force
1.20 jmc 55: .Nm
56: to use IPv6 addresses only.
1.37 djm 57: .It Fl c
58: Request certificates from target hosts instead of plain keys.
1.41 djm 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.
1.20 jmc 65: .It Fl f Ar file
66: Read hosts or
1.34 jmc 67: .Dq addrlist namelist
68: pairs from
69: .Ar file ,
70: one per line.
1.20 jmc 71: If
1.43 jmc 72: .Sq -
1.20 jmc 73: is supplied instead of a filename,
74: .Nm
1.43 jmc 75: will read from the standard input.
1.44 jmc 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
1.19 djm 80: .It Fl H
81: Hash all hostnames and addresses in the output.
82: Hashed names may be used normally by
1.43 jmc 83: .Xr ssh 1
1.19 djm 84: and
1.43 jmc 85: .Xr sshd 8 ,
1.19 djm 86: but they do not reveal identifying information should the file's contents
87: be disclosed.
1.10 markus 88: .It Fl p Ar port
1.43 jmc 89: Connect to
90: .Ar port
91: on the remote host.
1.11 stevesk 92: .It Fl T Ar timeout
1.15 jmc 93: Set the timeout for connection attempts.
94: If
1.34 jmc 95: .Ar timeout
1.1 markus 96: seconds have elapsed since a connection was initiated to a host or since the
1.43 jmc 97: last time anything was read from that host, the connection is
1.15 jmc 98: closed and the host in question considered unavailable.
1.43 jmc 99: The default is 5 seconds.
1.10 markus 100: .It Fl t Ar type
1.43 jmc 101: Specify the type of the key to fetch from the scanned hosts.
1.10 markus 102: The possible values are
1.29 djm 103: .Dq dsa ,
1.33 naddy 104: .Dq ecdsa ,
105: .Dq ed25519 ,
1.46 ! dtucker 106: .Dq ecdsa-sk ,
! 107: .Dq ed25519-sk ,
1.29 djm 108: or
1.40 jmc 109: .Dq rsa .
1.10 markus 110: Multiple values may be specified by separating them with commas.
1.30 djm 111: The default is to fetch
1.35 naddy 112: .Dq rsa ,
113: .Dq ecdsa ,
1.46 ! dtucker 114: .Dq ed25519 ,
! 115: .Dq ecdsa-sk ,
1.30 djm 116: and
1.46 ! dtucker 117: .Dq ed25519-sk
1.30 djm 118: keys.
1.10 markus 119: .It Fl v
1.43 jmc 120: Verbose mode:
121: print debugging messages about progress.
1.2 itojun 122: .El
1.43 jmc 123: .Pp
1.22 ray 124: If an ssh_known_hosts file is constructed using
1.9 mpech 125: .Nm
1.12 deraadt 126: without verifying the keys, users will be vulnerable to
1.18 brad 127: .Em man in the middle
1.9 mpech 128: attacks.
1.12 deraadt 129: On the other hand, if the security model allows such a risk,
1.9 mpech 130: .Nm
1.12 deraadt 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.
1.1 markus 133: .Sh FILES
1.13 deraadt 134: .Pa /etc/ssh/ssh_known_hosts
1.17 jmc 135: .Sh EXAMPLES
1.43 jmc 136: Print the RSA host key for machine
1.34 jmc 137: .Ar hostname :
1.43 jmc 138: .Pp
139: .Dl $ ssh-keyscan -t rsa hostname
1.17 jmc 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 :
1.43 jmc 145: .Bd -literal -offset indent
1.35 naddy 146: $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
1.17 jmc 147: sort -u - ssh_known_hosts | diff ssh_known_hosts -
148: .Ed
1.1 markus 149: .Sh SEE ALSO
1.4 deraadt 150: .Xr ssh 1 ,
1.1 markus 151: .Xr sshd 8
1.42 jmc 152: .Rs
153: .%D 2006
1.41 djm 154: .%R RFC 4255
1.42 jmc 155: .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
1.41 djm 156: .Re
1.7 mpech 157: .Sh AUTHORS
1.21 jaredy 158: .An -nosplit
1.31 schwarze 159: .An David Mazieres Aq Mt dm@lcs.mit.edu
1.10 markus 160: wrote the initial version, and
1.31 schwarze 161: .An Wayne Davison Aq Mt wayned@users.sourceforge.net
1.10 markus 162: added support for protocol version 2.