documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Document using ssh-keyscan to preload the deploy host host key.

Open leehambley opened this issue 13 years ago • 1 comments

The documentation should cover what a host key is, how to get one, and how to make a simple task to do this automatically, including any risks involved.


SSH-KEYSCAN(1)            BSD General Commands Manual           SSH-KEYSCAN(1)

NAME
     ssh-keyscan -- gather ssh public keys

SYNOPSIS
     ssh-keyscan [-46Hv] [-f file] [-p port] [-T timeout] [-t type] [host | addrlist namelist] ...

DESCRIPTION
     ssh-keyscan is a utility for gathering the public ssh host keys of a number of hosts.  It was
     designed to aid in building and verifying ssh_known_hosts files.  ssh-keyscan provides a minimal
     interface suitable for use by shell and perl scripts.

     ssh-keyscan 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.

Specifically you can do something liks this:

$ ssh [email protected]
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
^D
Host key verification failed.
$ ssh-keyscan github.com >> ~/.ssh/known_hosts
# github.com SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1+github5
$ cat ~/.ssh/known_hosts | grep github.com
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==

On Linux the output can also be sent to /etc/ssh/ssh_known_hosts to be globally applied, rather than for an individual user, with a privileged user account that is.

leehambley avatar Sep 23 '13 06:09 leehambley

This issue was moved to capistrano/capistrano#1765

leehambley avatar Aug 29 '16 08:08 leehambley