Annotation of src/usr.bin/ssh/ssh-keyscan.1, Revision 1.47
1.47 ! djm 1: .\" $OpenBSD: ssh-keyscan.1,v 1.46 2022/06/03 04:00:15 dtucker 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.47 ! djm 9: .Dd $Mdocdate: June 3 2022 $
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
1.47 ! djm 47: Hosts to be scanned may be specified by hostname, address or by CIDR
! 48: network range (e.g. 192.168.16/28).
! 49: If a network range is specified, then all addresses in that range will
! 50: be scanned.
! 51: .Pp
1.9 mpech 52: The options are as follows:
1.1 markus 53: .Bl -tag -width Ds
1.20 jmc 54: .It Fl 4
1.43 jmc 55: Force
1.20 jmc 56: .Nm
57: to use IPv4 addresses only.
58: .It Fl 6
1.43 jmc 59: Force
1.20 jmc 60: .Nm
61: to use IPv6 addresses only.
1.37 djm 62: .It Fl c
63: Request certificates from target hosts instead of plain keys.
1.41 djm 64: .It Fl D
65: Print keys found as SSHFP DNS records.
66: The default is to print keys in a format usable as a
67: .Xr ssh 1
68: .Pa known_hosts
69: file.
1.20 jmc 70: .It Fl f Ar file
71: Read hosts or
1.34 jmc 72: .Dq addrlist namelist
73: pairs from
74: .Ar file ,
75: one per line.
1.20 jmc 76: If
1.43 jmc 77: .Sq -
1.20 jmc 78: is supplied instead of a filename,
79: .Nm
1.43 jmc 80: will read from the standard input.
1.47 ! djm 81: Names read from a file must start with an address, hostname or CIDR network
! 82: range to be scanned.
! 83: Addresses and hostnames may optionally be followed by comma-separated name
! 84: or address aliases that will be copied to the output.
! 85: For example:
1.44 jmc 86: .Bd -literal
1.47 ! djm 87: 192.168.11.0/24
! 88: 10.20.1.1
! 89: happy.example.org
! 90: 10.0.0.1,sad.example.org
1.44 jmc 91: .Ed
1.19 djm 92: .It Fl H
93: Hash all hostnames and addresses in the output.
94: Hashed names may be used normally by
1.43 jmc 95: .Xr ssh 1
1.19 djm 96: and
1.43 jmc 97: .Xr sshd 8 ,
1.19 djm 98: but they do not reveal identifying information should the file's contents
99: be disclosed.
1.10 markus 100: .It Fl p Ar port
1.43 jmc 101: Connect to
102: .Ar port
103: on the remote host.
1.11 stevesk 104: .It Fl T Ar timeout
1.15 jmc 105: Set the timeout for connection attempts.
106: If
1.34 jmc 107: .Ar timeout
1.1 markus 108: seconds have elapsed since a connection was initiated to a host or since the
1.43 jmc 109: last time anything was read from that host, the connection is
1.15 jmc 110: closed and the host in question considered unavailable.
1.43 jmc 111: The default is 5 seconds.
1.10 markus 112: .It Fl t Ar type
1.43 jmc 113: Specify the type of the key to fetch from the scanned hosts.
1.10 markus 114: The possible values are
1.29 djm 115: .Dq dsa ,
1.33 naddy 116: .Dq ecdsa ,
117: .Dq ed25519 ,
1.46 dtucker 118: .Dq ecdsa-sk ,
119: .Dq ed25519-sk ,
1.29 djm 120: or
1.40 jmc 121: .Dq rsa .
1.10 markus 122: Multiple values may be specified by separating them with commas.
1.30 djm 123: The default is to fetch
1.35 naddy 124: .Dq rsa ,
125: .Dq ecdsa ,
1.46 dtucker 126: .Dq ed25519 ,
127: .Dq ecdsa-sk ,
1.30 djm 128: and
1.46 dtucker 129: .Dq ed25519-sk
1.30 djm 130: keys.
1.10 markus 131: .It Fl v
1.43 jmc 132: Verbose mode:
133: print debugging messages about progress.
1.2 itojun 134: .El
1.43 jmc 135: .Pp
1.22 ray 136: If an ssh_known_hosts file is constructed using
1.9 mpech 137: .Nm
1.12 deraadt 138: without verifying the keys, users will be vulnerable to
1.18 brad 139: .Em man in the middle
1.9 mpech 140: attacks.
1.12 deraadt 141: On the other hand, if the security model allows such a risk,
1.9 mpech 142: .Nm
1.12 deraadt 143: can help in the detection of tampered keyfiles or man in the middle
144: attacks which have begun after the ssh_known_hosts file was created.
1.1 markus 145: .Sh FILES
1.13 deraadt 146: .Pa /etc/ssh/ssh_known_hosts
1.17 jmc 147: .Sh EXAMPLES
1.43 jmc 148: Print the RSA host key for machine
1.34 jmc 149: .Ar hostname :
1.43 jmc 150: .Pp
151: .Dl $ ssh-keyscan -t rsa hostname
1.47 ! djm 152: .Pp
! 153: Search a network range, printing all supported key types:
! 154: .Pp
! 155: .Dl $ ssh-keyscan 192.168.0.64/25
1.17 jmc 156: .Pp
157: Find all hosts from the file
158: .Pa ssh_hosts
159: which have new or different keys from those in the sorted file
160: .Pa ssh_known_hosts :
1.43 jmc 161: .Bd -literal -offset indent
1.35 naddy 162: $ ssh-keyscan -t rsa,dsa,ecdsa,ed25519 -f ssh_hosts | \e
1.17 jmc 163: sort -u - ssh_known_hosts | diff ssh_known_hosts -
164: .Ed
1.1 markus 165: .Sh SEE ALSO
1.4 deraadt 166: .Xr ssh 1 ,
1.1 markus 167: .Xr sshd 8
1.42 jmc 168: .Rs
169: .%D 2006
1.41 djm 170: .%R RFC 4255
1.42 jmc 171: .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
1.41 djm 172: .Re
1.7 mpech 173: .Sh AUTHORS
1.21 jaredy 174: .An -nosplit
1.31 schwarze 175: .An David Mazieres Aq Mt dm@lcs.mit.edu
1.10 markus 176: wrote the initial version, and
1.31 schwarze 177: .An Wayne Davison Aq Mt wayned@users.sourceforge.net
1.10 markus 178: added support for protocol version 2.