432
iPhone_iPad_Mac_手機_平板_蘋果apple
SSH 登錄時出現如下錯誤:No supported key exchange algorithms__遠程登錄 (SSH)_Linux操作運維問題_雲服務器 ECS-阿裏雲
注意:本文相關配置及說明已在 CentOS 6.5 64 位操作係統中進行過測試。其它類型及版本操作係統配置可能有所差異,具體情況請參閱相應操作係統官方文檔。
,問題描述
,使用 ,SSH ,連接雲服務器 ,ECS ,(,Elastic Compute Server,) ,Linux ,服務器時,客戶端或服務端 ,secure ,日誌(可以通過 ,,,管理終端 ,進入係統查看)中可能會出現類似如下信息,導致無法正常連接服務器:
- Read from socket failed: Connection reset by peer.
- Connection closed by 192.168.0.1.
- sshd error: could not load host key.
- fatal: No supported key exchange algorithms [preauth].
- DSA host key for 192.168.0.1 has changed and you have requested strict checking.
- Host key verification failed.
- ,ssh_exchange_identification: read: Connection reset by peer.
,問題原因
,該問題通常是由於 ,SSH ,服務相關的密鑰文件異常所致,可能的原因包括:
- ,相關密鑰文件異常,比如文件損壞、被刪除或篡改等。
- ,,相關密鑰文件權限配置異常,導致無法正確讀取。
,處理辦法
,要解決此問題,針對前述不同情況,請依次進行如下配置檢查或修改:
檢查文件權限
SSH 服務會對相關密鑰文件的權限進行檢查。比如,私鑰文件默認權限是 600,如果配置成 777 等其它權限,導致其它用戶也有讀取或修改權限。則 SSH 服務會認為該配置存在安全風險,進而導致客戶端連接失敗。
可以通過如下指令恢複相關文件的默認權限配置:
cd /etc/ssh/
chmod 600 ssh_host_*
chmod 644 *.pub
操作示意如下:
[root@centos]# cd /etc/ssh/
[root@centos]# chmod 600 ssh_host_*
[root@centos]# chmod 644 *.pub
[root@centos]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 668 May 20 23:31 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:31 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:31 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:31 ssh_host_key.pub
-rw------- 1 root root 1675 May 20 23:31 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:31 ssh_host_rsa_key.pub
檢查文件有效性
,如果參閱前述步驟,修改相關文件權限後,還是無法正常連接。由於 ,SSH ,服務在啟動時會自動重建丟失的密鑰文件。所以,也可以直接將相關文件刪除並重啟 ,SSH ,服務,讓相關文件自動生成。
相關指令如下:
cd /etc/ssh/
rm -rf ssh_host_*
service sshd restart
,操作示意如下:
[root@centos]# cd /etc/ssh/
[root@centos]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 672 May 20 23:08 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:08 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:08 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:08 ssh_host_key.pub
-rw------- 1 root root 1675 May 20 23:08 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:08 ssh_host_rsa_key.pub
[root@centos]# rm -rf ssh_host_*
[root@centos]# ll
total 132
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
[root@centos]# service sshd restart
Stopping sshd: [ OK ]
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]
[root@centos]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 668 May 20 23:16 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:16 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:16 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:16 ssh_host_key.pub
-rw------- 1 root root 1671 May 20 23:16 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:16 ssh_host_rsa_key.pub
,補充說明:,對於 ,Ubuntu ,、,Debain ,類操作係統,修複指令如下:
sudo rm -r /etc/ssh/ssh*key
sudo dpkg-reconfigure openssh-server
,如果還有問題,可以參閱,雲服務器 ECS Linux SSH 無法登錄問題排查指引做進一步排查分析。
,更多信息
- ,SSH ,服務的連接交互過程,: ,更多關於,SSH ,服務的連接交互過程,可以參閱, ,,,雲服務器, ECS Linux SSH ,,連接交互過程簡介,。
,如果問題還未能解決,請聯係,,,售後技術支持,。
最後更新:2016-07-12 15:24:19
上一篇:
雲服務器 ECS Linux SSH 啟用 UseDNS 導致連接速度變慢__遠程登錄 (SSH)_Linux操作運維問題_雲服務器 ECS-阿裏雲
下一篇:
SSH 服務啟動時出現如下錯誤:must be owned by root and not group or word-writable__遠程登錄 (SSH)_Linux操作運維問題_雲服務器 ECS-阿裏雲
限製描述__DataHub實時數據通道_大數據計算服務-阿裏雲
如何申請專場培訓課程__專場培訓課程_上雲培訓-阿裏雲
服務市場條件__服務商入駐_服務商_雲市場-阿裏雲
SSH 連接時出現如下錯誤:error Could not get shadow infromation for root__遠程登錄 (SSH)_Linux操作運維問題_雲服務器 ECS-阿裏雲
什麼是公鑰和私鑰?__常見問題_產品常見問題_證書服務-阿裏雲
ALIYUN::RAM::ManagedPolicy__資源列表_資源編排-阿裏雲
網路連接相關問題__常見問題_專有網絡 VPC-阿裏雲
刪除集群實例__集群API列表_API參考_容器服務-阿裏雲
授權服務角色讀日誌__常見問題_產品使用問題_日誌服務-阿裏雲
設置發信地址__郵件設置_使用手冊_郵件推送-阿裏雲
相關內容
常見錯誤說明__附錄_大數據計算服務-阿裏雲
發送短信接口__API使用手冊_短信服務-阿裏雲
接口文檔__Android_安全組件教程_移動安全-阿裏雲
運營商錯誤碼(聯通)__常見問題_短信服務-阿裏雲
設置短信模板__使用手冊_短信服務-阿裏雲
OSS 權限問題及排查__常見錯誤及排除_最佳實踐_對象存儲 OSS-阿裏雲
消息通知__操作指南_批量計算-阿裏雲
設備端快速接入(MQTT)__快速開始_阿裏雲物聯網套件-阿裏雲
查詢API調用流量數據__API管理相關接口_API_API 網關-阿裏雲
使用STS訪問__JavaScript-SDK_SDK 參考_對象存儲 OSS-阿裏雲