0

I want to add an entry to my /etc/ssh/ssh_known_hosts file without running ssh-keyscan. I tried adding the public key but ssh complains, that the fingerprint does not match.

From the sshd man page:

SSH_KNOWN_HOSTS FILE FORMAT

 The /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts files contain host
 public keys for all known hosts.  The global file should be prepared by
 the administrator (optional), and the per-user file is maintained auto-
 matically: whenever the user connects to an unknown host, its key is
 added to the per-user file.

So my take from that would be, that one can add the public key data. However, it doesn't seem to work for me.

My ssh_known_hosts looks like this: (the key part matching the content of my public key file)

192.168.1.208 ssh-rsa AAAAB3Nza......zktpC1w==

running ssh-keyscan gives:

192.168.1.208 ecdsa-sha2-nistp256 AAAAE2V...2L0=
192.168.1.208 ssh-rsa AAAAB3Nza...38Ll
192.168.1.208 ssh-ed25519 AAAAC3Nza...m2Sc

So I can see, that the key shown for ssh-rsa ends differently from the content in my public key file.

How can I add the correct data to ssh_known_hosts file without ssh-keyscan?

(My environment: I use puttygen to create the keys, ssh-keygen etc. in a cygwin environment to convert as needed. Eventually the keys are used in Alpine linux VMs to ssh / scp between the VMs.)

  • You mean you created a user private/public key pair? This is different from the SSH host keys. If you want to authenticate a specific user, the user's public key has to go into `~/.ssh/authorized_keys on the target computer. – Thomas Dec 30 '18 at 12:29
  • Which key is correct? – Michael Hampton Dec 30 '18 at 18:26
  • Thanks for the comments - they brought me on the right track. There were a couple of copy and paste errors in my Vagrantfile and the puppet manifests. Fixing those made things work well. – Rainer Schwarze Jan 1 at 19:10

Your Answer

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

Browse other questions tagged or ask your own question.