Mac OS X删除SSH已知主机
使用Mac OS X通过ssh连接Linux:ssh [email protected]
得到一个错误,内容如下:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
如何在Mac OX X下解决此问题?
您需要运行以下命令来解决此问题。
打开终端应用程序,然后在macOS Unix系统上执行以下命令:
ssh-keygen -R server-name ssh-keygen -R server.ip.addre.ss ssh-keygen -R 192.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'
删除/Users/user/.ssh/known_hosts文件
我们将-R选项传递给ssh-keygen命令,以从known_hosts文件中删除属于指定主机名(带有可选端口号)的所有密钥。
此选项对于删除哈希主机很有用。
我们有一个~/.ssh/known_hosts文件,其中包含用户已登录的所有主机的主机密钥列表,而这些主机密钥尚未在系统范围内的已知主机密钥列表中。
测试一下
现在,您可以使用ssh或者sftp或者scp命令连接到远程主机:
ssh [email protected] ssh -p [email protected]
使用-p Port
使用给定的Port连接到远程主机。
可以在每个主机的配置文件(例如~/.ssh/config)中指定它。