運維小結之關於ssh登錄問題的解決方法

=== ssh登錄被拒的解決方法 ===
ssh登錄被拒,提示:ssh_exchange_identification: read: Connection reset by peer
可能原因:一./var/empty/sshd權限被更改爲777
服務器下進行如下操作
使用命令: service sshd stop
                        /usr/sbin/sshd -d
查看sshd服務的debug信息
若出現: /var/empty/sshd must be owned by root and not group or world-writable信息則/var/empty/sshd權限錯誤,進行下面的操作,修改/var/empty/sshd權限
  1.使用命令:ll  /var/empty
     查看當前empty文件夾權限,若爲drwxrwxrwx(777)
  2.修改/var/empty目錄權限
       命令:chmod 755 /var/empty/sshd
            或:chmod 711 /var/empty/sshd
3.重啓sshd服務
    service sshd restart
二.在客戶端使用sudo ssh 服務器IP -V若提示
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 116.196.90.60 [116.196.90.60] port 22.
debug1: connect to address 116.196.90.60 port 22: Connection refused
ssh: connect to host 116.196.90.60 port 22: Connection refused
則表明主機IP被服務器拒絕訪問,該問題通常是由於 Linux 系統通過 /etc/hosts.allow 或 /etc/hosts.deny,啓用了 TCP Wrapper  訪問控制所致。
可在服務器端作如下操作:
1.檢查/etc/hosts.deny中是否有
sshd:客戶端IP地址
或在 /etc/hosts.allow 或 /etc/hosts.deny中有
all:all:deny
2.若出現上述情況將sshd:客戶端IP地址   all:all:deny註釋或刪除
一般情況,備份並修改/etc/hosts.allows添加如下命令
sshd:客戶端IP地址
(有博友給出的方法是將/etc/hosts.allow修改爲sshd:ALL,針對我個人遇到的問題該方法親測可行,但感覺並不安全)
問題解決參考以下博文:http://yanue.net/post-163.html
                                        https://help.aliyun.com/knowledge_detail/41485.html
                                        http://blog.csdn.net/woshizhangliang999/article/details/50563247      
                                  http://www.cnblogs.com/starof/p/4709805.html             
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章