一般xshell連接linux服務器不成功有以下幾個問題:
- linux防火牆攔截,導致Xshell不能訪問linux
操作方法:
firewalld(CentOS7):啟動 :systemctl start firewalld
關閉:systemctl stop firewalld
查看狀態:systemctl status firewalld
開機禁用:systemctl disable firewalld
開機啟用:systemctl enable firewalld
iptables防火牆的操作方法與firewalld防火牆相同,只是在不同環境下可能需要將 systemctl 換成service
- 22端口被占用
查看方法:netstat -tunlp|grep 22 查看端口使用情況
lsof -i:22 查看端口屬於哪一個程序
如果不是sshd進程的話 則 kill -9 進程id 殺死進程
- 修改sshd_config配置文件
用root權限打開 /etc/ssh/sshd_config文件
修改 PermitRootLogin no 改為 PermitRootLogin yes
之后重啟服務 service sshd restart
筆者執行完以上三種方式扔仍沒有解決問題,最后發現在登錄linux虛擬機時輸入的密碼是按的鍵盤右側的數字鍵。因為當時的數字鍵是鎖定的狀態,輸入時並不是輸入的空,而是其他字符,導致root密碼根本就不是自己記錄的密碼。所以當在xshell里面輸入密碼時因為密碼錯誤登錄不上。
因為這個問題耽誤了兩天的時間,實在是烏龍,記錄在冊,希以鞭策。