ssh登陆失败
ssh登陆是失败:
$ ssh test@192.168.0.22
ssh: connect to host 192.168.0.22 port 22: Connection timed ou
1, 网络通不通?
$ ping 192.168.0.22
PING 192.168.0.22 (192.168.0.22) 56(84) bytes of data.
64 bytes from 192.168.0.22: icmp_seq=1 ttl=63 time=0.662 ms
64 bytes from 192.168.0.22: icmp_seq=2 ttl=63 time=0.664 ms
64 bytes from 192.168.0.22: icmp_seq=3 ttl=63 time=0.613 ms
网络正常,如果网络不通,需要看看网络设置正确没.
2, ssh安装了吗?
如果网络正常,依然不能登陆,则查看ssh service有没有启动:
$ sudo service ssh restart
ssh: unrecognized service
ssh没有安装,需要安装ssh
$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
ssh start/running, process 5650
Setting up ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
安装完成后,再次查看
$ sudo service ssh restart
ssh stop/waiting
ssh start/running, process 568
3, 防火墙设置正常吗?
service也启动了,依然不能登陆,则通ufw查看防火墙状况:
$ sudo ufw status
Status: active
To Action From
-- ------ ----
8810 ALLOW Anywhere
8810 (v6) ALLOW Anywhere
通过ufw看到 22端口没有被允许,因此ssh 登陆不上,ufw 添加端口号22:
$ sudo ufw allow 22
Rule added
Rule added (v6)
$ sudo ufw status
Status: active
To Action From
-- ------ ----
8810 ALLOW Anywhere
22 ALLOW Anywhere
8810 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
可以看到22已经allow,一般到这里,已经可以登陆了;如果不需要防火墙,可以关闭:
$ sudo ufw disable
Firewall stopped and disabled on system startup
$ sudo ufw status
Status: inactive