Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
echo gvcentostest $(cat gvcentostest/etc/ssh/>>All/etc/ssh/ssh_known_hosts did it. My question was caused by my frustration about the content of /etc/ssh/ 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 posting your answer, you agree to the privacy policy and terms of service.

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