remove domain from ssh known_hosts file
Jun
11
1
3
ssh-keygen -R <domain> ssh keygen -R example.com ssh-keygen -R [localhost]:22
ssh-keygen -R <domain> ssh keygen -R example.com ssh-keygen -R [localhost]:22
Sometimes I re-key or move the domain of a server and need to reset the key so RSA doesn't complain. Technically you can just open ~/.ssh/known_hosts file and remove the entry for the dns, but the names are hashed which makes the entry difficult to find.
I used to just reset the entire known_hosts file, but that's not necessary. You can remove the domain entry with the simple command:
ssh-keygen -R example.com
Next time you try to ssh you'll be prompted to add the key as if you're visiting the site the first time. I hope this helps.
Depending on how your server is set up you might be required to log into it using a public key (for me I needed this for my Amazon instances). This is fine with SSH, you can just link to it directly when like so:
ssh user@example.com -i /path/to/example.pem
I had a problem with SFTP since it doesn't have the -i option. I got around this issue by associating the public key file to the ssh connection.
Create a <config> file in your .ssh folder, and write an entry similar to the following example:
host example.com IdentityFile ~/.ssh/example.pem
You should then be able to log in through ssh and sftp without having to specify a public key file since it's automatically associated with the host.