I am trying to copy a public key from Server A over to the known_hosts file in Server B. They are both linux servers. Initially I thought about opening the public key file and copying its contents over to the known_hosts file but I suspect that is not the correct method. Does anyone know what the right way to do so is?
My public key is in the format ssh-rsa AADGD...
Can someone help?
Thanks!
On your computer, in the PuTTYgen utility, copy the contents of the public key (displayed in the area under "Key") onto your Clipboard. Then, on the remote system, use your favorite text editor to paste it onto a new line in your ~/. ssh/authorized_keys file, and then save and close the file.
The known_hosts file contains the host public key for all known hosts. The use of this file is optional, but, if used then it is prepared by the system administrator. It automatically maintains the per-user file in the system.
authorized_keys is a file that allows you to add ssh public keys of users that should be allowed to log into your server (the server in which the authorized_keys file lives) using key based auth. known_hosts is a file that contains a list of keys from... known hosts that you have logged into.
I answered almost similar answer on SuperUser few days ago. The important parts:
ssh-keyscan
which can create the format for youOtherwise just prefix your key with server IP address (you can add also hostname, after comma), remove the comment from end of the line and you are fine. Format then look like this:
11.22.33.44 ssh-rsa AADGD...
And one more note, if you use HashKnownHosts yes
(Debian and Ubuntu does), you need to re-hash your known_hosts
such as:
ssh-keygen -Hf ~/.ssh/known_hosts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With