2011 / 08 / 05
Updating known_hosts
Host keys
Ssh uses host keys to prevent man-in-the-middle attacks. By default the host keys are generated when the Operating System is installed or, depending on the OS, if no key is present when sshd is restarted. There are different ways to manage host keys such as distributing a comprehensive known_hosts file and adding the fingerprints in DNS, but most sites use the default configuration.
The known_hosts file
The ssh client keeps a copy of the public host keys of machines it has already connected to in the known_hosts file. When it connects to a machine for the first time, it warns the user and prompts them to update the known_hosts file:
Also, it will not connect to a machine for which the host keys have been changed, and give a warning:
When communication between machines needs to be automated, such as with MPI in a High-Performance Computing (HPC) cluster, this becomes a problem.
The "trust" script

- passwordless ssh is needed
- using "StrictHostKeyChecking no" is not an option
- host keys are not managed
- machines are rebuilt and new ones added on a regular basis
- it can be guaranteed that the machines on the network have not been compromised, nor spoofed
Updating the known_hosts can be scripted. "trust" is a small script which will remove old keys and add the new ones in the known_hosts file for a given host. It can be used to refresh the key for one machine, or all the nodes:
atom feed