如何解決無法通過SSH或SFTP連線伺服器問題

錯誤型別:
其他錯誤
錯誤名稱:
无法通过SSH或SFTP连接服务器
英文名稱:
Host key verification failed
錯誤描述:
这通常是因为IP地址或SSH密钥指纹已更改(通常是由于服务器更新),而旧的仍存储在您的known_hosts文件中,该文件用于SSH和SFTP连接。

如何解決無法通過SSH或SFTP連線伺服器問題

通過SSH或SFTP連線時遇到問題?如果您收到如下所示的錯誤,這通常是因為IP地址或SSH金鑰指紋已更改(通常是由於伺服器更新),而舊的仍儲存在您的known_hosts檔案中,該檔案用於SSH和SFTP連線。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[user@hostname ~]$ ssh root@user
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 RSA key sent by the remote host is
xx:xx:xx.
Please contact your system administrator.
Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
RSA host key for user has changed and you have requested strict checking.
Host key verification failed.
[user@hostname ~]$ ssh root@user @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 RSA key sent by the remote host is xx:xx:xx. Please contact your system administrator. Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message. Offending RSA key in /var/lib/sss/pubconf/known_hosts:4 RSA host key for user has changed and you have requested strict checking. Host key verification failed.
[user@hostname ~]$ ssh root@user
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 RSA key sent by the remote host is
xx:xx:xx.
Please contact your system administrator.
Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
RSA host key for user has changed and you have requested strict checking.
Host key verification failed.

如果您在連線時遇到問題,請首先確保您使用的是正確的密碼。

如果仍有問題,請按照以下說明從known_hosts檔案中刪除條目。

Mac或Linux

1.開啟終端並使用nano文字編輯器編輯以下檔案。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano ~/.ssh/known_hosts
nano ~/.ssh/known_hosts
nano ~/.ssh/known_hosts

2.刪除所有以您的伺服器IP地址開頭的條目。

3.然後儲存文件 (Ctrl+x)。

Windows

如果您使用的是Windows,它也有一個類似的known_hosts檔案,但憑據和IP儲存在登錄檔中。

1.從開始選單啟動regedit。下面的示例使用的是Windows 10。

 

Windows登錄檔編輯器

Windows登錄檔編輯器

 

2.瀏覽到以下目錄:HKEY_CURRENT_USERSoftWareSimonTathamPuTTYSshHostKeys

 

SSH主機金鑰

SSH主機金鑰

 

3.刪除所有以您的伺服器IP地址結尾的條目。

評論留言