How to add PEM file as SSH private key to "known hosts"

Solution 1:

I don't know about different types of SSH keys. But you would put the public key on the destination computer, not your private key. Your private key stays private.

And the public key of the source computer should be placed on the dest computer in ~/.ssh/authorized_keys This can be done manually or via the ssh-keygen command.

I suggest you do cat on the public key on the source computer and cat on authorized_keys on the dest computer and make sure the source's one looks like it is the same format as those in authorized_keys

The known_hosts file is something which gets appended to automatically. You don't need to edit it manually. You can connect even after deleting the known_hosts file.

EDIT-

To incorporate some of the comments into the answer. The public key comes from the private key. Normally the private key stays private, but the OP was being given a private key, this is unusual, but it's an interesting way of doing it, because it means the dest computer can then already have his public key. So he could log in without having to add anything to the dest computer's authorized_keys. ssh -i always takes a private key. He need only do ssh -i path/to/privatekeyfile user@dest The OP is using "openstack", some cloud service, and as the openstack site says docs.openstack.org/user-guide/content/ssh-into-instance.html $ ssh -i MyKey.pem [email protected] So whatever the name of the private key file is, and wherever it is stored, you specify that when doing ssh -i