Mac OS X Remove SSH Known Host Print

  • ssh, Terminal, mac, os, macos, connect, server, hostname
  • 0

‘ve reinstalled Linux on remote server and now trying to connect it over ssh using Mac OS X:
ssh [email protected]

But I’m getting an error which read as follows:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5c:9b:16:56:a6:cd:11:10:3a:cd:1b:a2:91:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /Users/user/.ssh/known_hosts to get rid of this message.
Offending key in /Users/user/.ssh/known_hosts:1
RSA host key for server1.example.com has changed and you have requested strict checking.
Host key verification failed.

 

How do I fix this problem under Mac OX X?

You need to run the following command to get rid of this problem. Open the terminal application and then type the following command on your macOS Unix system:

 

ssh-keygen -R server-name
ssh-keygen -R server.ip.addre.ss
ssh-keygen -R 202.54.1.5
ssh-keygen -R server1.example.com
## for non-standard ssh port ##
ssh-keygen -R 'server1.example.com:PORT'
ssh-keygen -R 'server1.example.com:4122'

 

 

We pass the -R option to the ssh-keygen command to remove all keys belonging to the specified hostname (with optional port number) from a known_hosts file. This option is useful to delete hashed hosts. We have ~/.ssh/known_hosts file which contains a list of host keys for all hosts the user has logged into that are not already in the systemwide list of known host keys.

Test it

Now you can connect to remote host with ssh or sftp or scp command:

ssh user@server1.example.com
ssh -p user@server1.example.com

Was this answer helpful?

« Back