10

How do I delete ALL SSH known hosts?

I've managed many VPSs before and I want to delete these keys.

1
12

First of all you should remember to verify ssh key finger prints when connecting to a remote computer for the first time, to avoid MITM attacks.

Having said that, first making a backup, and then removing all previous ssh known hosts is a matter of doing this on your local computer :

cp -av ~/.ssh/known_hosts ~/.ssh/known_hosts-old
rm ~/.ssh/known_hosts

The known_hosts file will be created again after you completely initiated the first new ssh session.

1
  • 9
    Why cp then rm instead of just mv? Feb 1 '17 at 22:58

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.