How can I create an entry in a ssh known_hosts file from hostname and host key?

I want to do it without trying to connect to the remote system, automaticaly loading the key over untrusted network and adding it to ~/.ssh/known_hosts by answering "yes" and hoping that there is currently no man in the middle attac. Instead I want to go to the remote system copy some files from /etc/ssh to an USB storage pen, or floppy disk, carry that media to the other system and create the known_hosts entry from the content of that media.


hostname,ip ssh-rsa keycontentshere

ssh-rsa might be different if the key is generated using AES or another method. Of course, making a connection to the machine in question should automatically create the host key.

  • 1
    echo gvcentostest $(cat gvcentostest/etc/ssh/ssh_host_rsa_key.pub)>>All/etc/ssh/ssh_known_hosts did it. My question was caused by my frustration about the content of /etc/ssh/ssh_host_key.pub which doesn't fit to the known_hosts files. Thank you for the answer. It made me have a closer look into /etc/ssh . I do apologize. – Matthias Müller-Reineke Jul 1 '10 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.