在本地命令行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 文件,使其不包含旧的公钥信息即可
- 直接删除known_hosts文件
known_hosts.old是一个备份文件,只有将它的后缀删除才会生效
- 找出known_hosts中原ssh服务器的公钥,删去那部分即可
然后后再次建立新的连接,即可获得新的公钥啦