ssh登陸異常

情景描述:
開發同事報告使用某普通用戶test沒法遠程登錄一臺,報錯「shell request failed on channel 0」。
解決過程
markhtml

  • 判斷內存空間是否充足
  • 查看用戶是否存在(排除誤操做刪除用戶的可能)
  • 查看公鑰文件(authorized_kys),ssh配置文件(.ssh/config)以及自定義的公鑰文件(id_rsa_gitlab_deploy)
  • 使用w查看當前終端在線的用戶
  • "lsof /dev/pts/*"查看當前服務器中文件描述符被哪些進程佔用
  • 使用sudo su test嘗試登陸服務器,報錯:「su: failed to execute /bin/bash: 資源暫時不可用」==>大概定位爲FD資源不足
  • 執行lsof命令,列出當前系統打開文件的工具,同時會顯示進程的狀態,此時發現有好多close_wait進程
  • 進一步確認,爲代碼問題,告知相關開發人員
  • kill掉進程(非線上重要進程,kill前和開發溝通好),開發人員修復後本身啓動。

2018/02/26
今天,在作jenkins的時候ssh到另外一臺Linux機器失敗!報錯以下git

[root@Dasoncheng ~]# ssh root@192.168.60.12
root@192.168.60.12's password:
##我已經把公鑰放在服務端了,仍是讓我輸入密碼;我就重啓了一下服務端 結果:
[root@Dasoncheng ~]# ssh root@192.168.60.12
ssh_exchange_identification: read: Connection reset by peer
##等待了一會 結果報上面的錯誤。我就百度了

解決方法:shell

[root@Dasoncheng2 var]# cd /var/
[root@Dasoncheng2 var]# chmod -R 755 *
繼續百度,又跑到一個歪果仁的網站上,在一個不起眼論壇的一個不起眼的帖子中一個不起眼的跟帖中,一個哥們很低調的說了句「I know this quesiton is old ,
but I wanted to share some findings I had,Check if /var/empty/sshd on the server has appropriate ownership and permissions.
We had a chef script that was modifile toupdate some directory peimisions,but indavertently updated the diectory below the 
intended target,chaning ownership of /var to an applicaton user/group and changing the permissons to 755."
去/var下看了看,果真權限很大,都是777,cd 到 empty 目錄,果真有ssh這個文件夾,在cd進去,啥也沒有了。因而直接執行兩條命令: 
cd /var 
chmod -R 755 * 
而後就再次嘗試了遠程鏈接了下,居然ok了。

mark
原文連接:http://blog.csdn.net/x6_9x/article/details/49983607
一個很是棒的ssh登陸失敗 排錯經驗:https://www.cnblogs.com/starof/p/4709805.htmlbash

相關文章
相關標籤/搜索