錯誤一:Unable to authenticate
The client has disconnected from the server. Reason:Unable to authenticate using any of the configured authentication methods.
意思是無法進行身份驗證
,這個錯誤信息比較模糊,無法馬上確定,排查可能是以下原因導致:
SSH客戶端沒有開啓密碼驗證
或者SSH服務端不允許密碼驗證
也有可能是SSH Keys錯誤(丟失/損壞/不匹配)
換用Terminal SSH連接
這麼做是因爲我之前一直是用SecureCRT正常連接的,最近纔開始報這個錯,所以很可能是SecureCRT的本地連接數據出了問題,而換用Terminal連接則可排除這個問題。
#連接SSH $ ssh -p 22 root@IP
如果出現了登錄login輸入,則說明確定是SecureCRT問題,這時候只要刪除SecureCRT裏的連接重新建立一個就可解決。如果沒問題login繼續往下看。
確認SSH配置
檢查/etc/ssh/sshd_config
的 PasswordAuthentication yes
,去掉註釋,保存,重啓ssh服務:service sshd restart
。
再嘗試連接,如果錯誤消失,解決,否則繼續下面。
因爲訪問權限被拒絕
登陸服務器查看auth.log
cat auth.log 15 11:20:24 hp06 sshd[31533]: Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys
解決辦法:chmod 600 /home/user/.ssh/authorized_keys
,這裏根據你的日誌來。
SSH證書不匹配
一般不會是這個原因,但如果以上的方法都無用,你需要把pem
證書轉爲pub
證書,並手動指定路徑,問題解決。
錯誤二:Protocol version mismatch
The client has disconnected from the server. Reason: Protocol version mismatch. Required protocol version is 1.3 - 1.99. Received version was 2.0.
提示很明確,是連接協議版本不匹配
,解決方法修改成SSH2就行: