ssh连接报错: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!Host key verification failed.

在本地命令行ssh连接服务器报错:

OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 47.113.179.190 [47.113.179.190] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\22939/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\22939/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\22939/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ecdsa_sk type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ed25519_sk type -1
debug1: identity file C:\\Users\\22939/.ssh/id_ed25519_sk-cert type -1
debug1: identity file C:\\Users\\22939/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\22939/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: compat_banner: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000002
debug1: Authenticating to 47.113.179.190:22 as 'git'
debug1: load_hostkeys: fopen C:\\Users\\22939/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:j737lnH1pMeXyOhmEL+2Fd+1QxXgF9pUm8qtXqQyGkE
debug1: load_hostkeys: fopen C:\\Users\\22939/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ED25519 key sent by the remote host is
SHA256:j737lnH1pMeXyOhmEL+2Fd+1QxXgF9pUm8qtXqQyGkE.
Please contact your system administrator.
Add correct host key in C:\\Users\\22939/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\22939/.ssh/known_hosts:3
Host key for 47.113.179.190 has changed and you have requested strict checking.
Host key verification failed.

原因是所连接的服务器的公钥发生了变动,可能你之前已经保存了改服务器的公钥,而这次的公钥与之前的不符。
之前连接该服务器的公钥会被保存在~/.ssh/known_hosts文件中

解决办法:
由于远程主机的密钥已经发生了变化,可能是由于服务器重新安装了 SSH 或其他原因,本地的 known_hosts 文件中保存的公钥信息不再匹配。为了解决这个问题,只需要清理本地 known_hosts 文件,使其不包含旧的公钥信息即可

  1. 直接删除known_hosts文件

在这里插入图片描述

known_hosts.old是一个备份文件,只有将它的后缀删除才会生效

  1. 找出known_hosts中原ssh服务器的公钥,删去那部分即可

然后后再次建立新的连接,即可获得新的公钥啦

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值