![Forrest logo](/images/logo.png)
ssh:tldr:78f8e
ssh: Manually update the ssh known_hosts file with the fingerprint of a given host.
$ ssh-keyscan -H ${host} >> ~/.ssh/known_hosts
try on your machine
This command is used to add a host's public key to the known_hosts file in the user's .ssh directory.
Here is a breakdown of the command:
- ssh-keyscan: This is a utility used to gather a remote host's public SSH key.
- -H: It tells ssh-keyscan to include the hostnames of the scanned keys in the output.
- ${host}: This is a placeholder for the hostname or IP address of the target host. It should be replaced with the actual value.
-
~/.ssh/known_hosts: The double chevron (>>) is a shell redirection operator that appends the output of the preceding command to the specified file (in this case, known_hosts in the .ssh directory of the current user).
Putting it all together, this command scans the SSH public key of a specified host and appends it to the user's known_hosts file, which is used by SSH clients to verify the host's authenticity. By adding the public key to this file, SSH connections to the host in the future will not prompt the user for confirmation, as the key is already known and trusted.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.