I am scripting a remote rsync setup, and need to add a remote server to the local known_hosts file to avoid getting prompted wit the below when the script is first ran:
The authenticity of host '[hostname] ([IP address])' can't be established.
RSA key fingerprint is [key fingerprint].
Are you sure you want to continue connecting (yes/no)?
As per Can I automatically add a new host to known_hosts? I have tried (with a fresh known_hosts file):
ssh-keyscan -H [hostname],[ip_address] >> ~/.ssh/known_hosts
ssh-keyscan -H [ip_address] >> ~/.ssh/known_hosts
ssh-keyscan -H [hostname] >> ~/.ssh/known_hosts
But this does not work, I am always prompted to accept the finger-print.
When I do let ssh add this for me, the key hash is very different in the know_hosts file.
What else should I do to troubleshoot this issue?
Best Answer
Try this:
Take the output and paste it in .ssh/known_hosts. Now if you want to hash known_hosts do this:
edit: Heres the one command solution. It uses hostname and IP addresses and hashes both.