Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/openssh/man/ssh-keyscan.1

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TH SSH-KEYSCAN 1 "June 5 2007 " ""
.SH NAME
\fBssh-keyscan\fP
\- gather ssh public keys
.SH SYNOPSIS
.br
\fBssh-keyscan\fP
[\fB\-46Hv\fP]
[\fB\-f\fP \fIfile\fP]
[\fB\-p\fP \fIport\fP]
[\fB\-T\fP \fItimeout\fP]
[\fB\-t\fP \fItype\fP]
[\fIhost\fP | \fIaddrlist\fP namelist]
[\fI...\fP]
.SH DESCRIPTION
\fBssh-keyscan\fP
is a utility for gathering the public ssh host keys of a number of
hosts.
It was designed to aid in building and verifying
\fIssh_known_hosts\fP
files.
\fBssh-keyscan\fP
provides a minimal interface suitable for use by shell and perl
scripts.

\fBssh-keyscan\fP
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.

The options are as follows:
.TP
\fB\-4\fP
Forces
\fBssh-keyscan\fP
to use IPv4 addresses only.
.TP
\fB\-6\fP
Forces
\fBssh-keyscan\fP
to use IPv6 addresses only.
.TP
\fB\-f\fP \fIfile\fP
Read hosts or
\fIaddrlist\fP namelist
pairs from this file, one per line.
If
\fI-\fP
is supplied instead of a filename,
\fBssh-keyscan\fP
will read hosts or
\fIaddrlist\fP namelist
pairs from the standard input.
.TP
\fB\-H\fP
Hash all hostnames and addresses in the output.
Hashed names may be used normally by
\fBssh\fP
and
\fBsshd\fP,
but they do not reveal identifying information should the file's contents
be disclosed.
.TP
\fB\-p\fP \fIport\fP
Port to connect to on the remote host.
.TP
\fB\-T\fP \fItimeout\fP
Set the timeout for connection attempts.
If
\fItimeout\fP
seconds have elapsed since a connection was initiated to a host or since the
last time anything was read from that host, then the connection is
closed and the host in question considered unavailable.
Default is 5 seconds.
.TP
\fB\-t\fP \fItype\fP
Specifies the type of the key to fetch from the scanned hosts.
The possible values are
``rsa1''
for protocol version 1 and
``rsa''
or
``dsa''
for protocol version 2.
Multiple values may be specified by separating them with commas.
The default is
``rsa1''.
.TP
\fB\-v\fP
Verbose mode.
Causes
\fBssh-keyscan\fP
to print debugging messages about its progress.
.SH SECURITY
If an ssh_known_hosts file is constructed using
\fBssh-keyscan\fP
without verifying the keys, users will be vulnerable to
.IR man in the middle
attacks.
On the other hand, if the security model allows such a risk,
\fBssh-keyscan\fP
can help in the detection of tampered keyfiles or man in the middle
attacks which have begun after the ssh_known_hosts file was created.
.SH FILES
\fIInput\fP format:

1.2.3.4,1.2.4.4 name.my.domain,name,n.my.domain,n,1.2.3.4,1.2.4.4
.br

\fIOutput\fP format for rsa1 keys:

host-or-namelist bits exponent modulus
.br

\fIOutput\fP format for rsa and dsa keys:

host-or-namelist keytype base64-encoded-key
.br

Where
\fIkeytype\fP
is either
``ssh-rsa''
or
``ssh-dss''.

\fI/etc/ssh/ssh_known_hosts\fP
.SH EXAMPLES
Print the
\fIrsa1\fP
host key for machine
\fIhostname\fP:

$ ssh-keyscan hostname
.br

Find all hosts from the file
\fIssh_hosts\fP
which have new or different keys from those in the sorted file
\fIssh_known_hosts\fP:

$ ssh-keyscan -t rsa,dsa -f ssh_hosts | \e
.br
	sort -u - ssh_known_hosts | diff ssh_known_hosts -
.br
.SH SEE ALSO
\fBssh\fP(1),
\fBsshd\fP(8)
.SH AUTHORS

-nosplit

David Mazieres <[email protected]>
wrote the initial version, and

Wayne Davison <[email protected]>
added support for protocol version 2.
.SH BUGS
It generates "Connection closed by remote host" messages on the consoles
of all the machines it scans if the server is older than version 2.9.
This is because it opens a connection to the ssh port, reads the public
key, and drops the connection as soon as it gets the key.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].