1. 程式人生 > >ssh 不能連線伺服器!

ssh 不能連線伺服器!

 今天用ssh連線伺服器的時候一直報這個錯誤

$ 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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Kv8AqNW+DjkUVRiwWjpxkt/XT6tVbtmy1miSvPg+vDE.
Please contact your system administrator.
Add correct host key in /c/Users/Administrator/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/Administrator/.ssh/known_hosts:5
ECDSA host key for XX.XX.XX.XX has changed and you have requested strict checking.
Host key verification failed.

查資料後發現兩種解決方法(其實都一樣)

1,執行以下命令刪除有關XX.XX.XX.XX的內容

vi ~/.ssh/known_hosts

2,直接執行以下命令刪除

ssh-keygen -R XX.XX.XX.XX

 然後重新連線伺服器即可

$ ssh [email protected]
The authenticity of host 'XX.XX.XX.XX (XX.XX.XX.XX)' can't be established.
ECDSA key fingerprint is SHA256:Kv8AqNW+DjkUVRiwWjpxkt/XT6tVbtmy1miSvPg+vDE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'XX.XX.XX.XX' (ECDSA) to the list of known hosts.
[email protected]
's password: Last failed login: Fri Oct 12 12:09:33 CST 2018 from 104.248.50.163 on ssh:notty There was 1 failed login attempt since the last successful login. Welcome to Alibaba Cloud Elastic Compute Service ! [[email protected] ~]#