1. 程式人生 > >用xshell 連線伺服器提示:Could not connect to '192.168.0.104' (port 22): Connection failed.

用xshell 連線伺服器提示:Could not connect to '192.168.0.104' (port 22): Connection failed.

xshell 連線伺服器時提示:

Could not connect to '192.168.0.104' (port 22): Connection failed.
的解決方法如下:

(1)、檢視網路是否連通

ping 192.168.0.104

正在 Ping 192.168.0.104 具有 32 位元組的資料:
來自 192.168.0.104 的回覆: 位元組=32 時間=1ms TTL=64
來自 192.168.0.104 的回覆: 位元組=32 時間<1ms TTL=64
來自 192.168.0.104 的回覆: 位元組=32 時間<1ms TTL=64

若能ping通則證明網路連通,問題出在伺服器埠,否則需要設定伺服器網路,直至能ping通。然後執行(2)


(2)、檢查伺服器防火牆是否關閉或者22埠是否開啟

(方法一)關閉防火牆:

sudo ufw disable

(方法二)防火牆開啟時只打開22埠:

sudo ufw allow 22


(3)、檢視ssh服務是否安裝及開啟 檢視伺服器是否安裝ssh:
ps -e |grep ssh
若無安裝執行以下命令:
sudo apt-get install openssh-server
開啟ssh服務:
/etc/init.d/ssh start 

到此即可成功使用xshell進入伺服器