手机版
你好,游客 登录 注册
背景:
阅读新闻

更换主机后SSH无法登录解决

[日期:2016-04-05] 来源:Linux社区  作者:vdvvdd [字体:大 中 小]

之前通过SSH远程一台机器(起个名字:linuxidc),某一天把cc重装了一下系统,再SSH时显示密钥验证失败:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
1e:10:25:81:de:bc:74:92:08:51:ff:ab:49:8d:69:39.
Please contact your system administrator.
Add correct host key in /home/username/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/username/.ssh/known_hosts:6
  remove with: ssh-keygen -f "/home/username/.ssh/known_hosts" -R ***.***.***.
ECDSA host key for ***.***.***.*** has changed and you have requested strict checking.***
Host key verification failed.

当client通过ssh连接server时,会把server的信息保存在自己家目录下的.ssh/known_hosts文件里。如果server被重装或者被替换(IP没变),server的信息肯定就改变了,与之前known_hosts里的信息不一致,从而导致密钥认证失败。

解决方法也很简单,根据上面的提示信息,server的信息在/home/username/.ssh/known_hosts:6,直接把known_hosts里server的信息删掉即可。命令也给出来了:

ssh-keygen -f "/username/username/.ssh/known_hosts" -R ***.***.***.

(该命令会生成known_hosts.old,即原文件的备份)。

再次连接时就会给出主机新的ECDSA key。

感兴趣的可以看看SSH的原理

下面关于SSH相关的文章您也可能喜欢,不妨参考下:

Ubuntu 下配置 SSH服务全过程及问题解决 http://www.linuxidc.com/Linux/2011-09/42775.htm

Ubuntu 14.04 下安装Samba 及SSH 服务端的方法 http://www.linuxidc.com/Linux/2015-01/111971.htm

SSH服务远程访问Linux服务器登陆慢 http://www.linuxidc.com/Linux/2011-08/39742.htm

提高Ubuntu的SSH登陆认证速度的办法 http://www.linuxidc.com/Linux/2014-09/106810.htm

开启SSH服务让Android手机远程访问 Ubuntu 14.04  http://www.linuxidc.com/Linux/2014-09/106809.htm

如何为Linux系统中的SSH添加双重认证 http://www.linuxidc.com/Linux/2014-08/105998.htm

在 Linux 中为非 SSH 用户配置 SFTP 环境 http://www.linuxidc.com/Linux/2014-08/105865.htm

Linux 上SSH 服务的配置和管理 http://www.linuxidc.com/Linux/2014-06/103627.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-04/129849.htm

linux
相关资讯       SSH登录 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款