Deleting Known_Hosts file for .ssh authentication errors (Mac)

When accessing an endpoint via .ssh from a Mac for the first time, there is an authentication that occurs which matches a key on the remote host to a directory entry on your machine.  If there is no entry already in place on your machine, you will simply be prompted to approve the connection by entering ‘yes’ at the prompt.  However, if you already have a key in your  /users/<username>/.ssh/Known_Hosts  file, you can be prompted with a much more sinister message:

This requires a more aggressive approach.  You will need to delete the key from your directory by doing the following:

From your Terminal window: You should have a prompt that ends with a $ sign.

1. $open /Users/username/.ssh/known_hosts

2. This will open a text editor that displays all of your keys.  It will be formatted as first an IP address followed by the keys associated with that address.

3. Delete all the keys immediately following that IP address

Tags: , ,

Related posts

  • Rob Jewitt

    Hi – hoping anyone can help here. I failed at the step 1. I used the code in Terminal but swapped out username for my OSX username and got a “Permission denied” message. Any ideas?

    • Jeff Hubbard

      Hmmm…First, I’d try to ensure that the username in question has full admin rights, and that you are logged into the machine under that username. Also, ensure there is a space after the “open” command. If this doesn’t work, feel free to email me a screen shot of your error and I’ll be happy to try and help further.