Xshell链接错误:Could notconnect to ‘192.168.18.128’ (port 22): Connection failed.
还有一种可能就是你的sshd服务被Gank了。可以先去服务器看下22的默认端口是否还开启
1.查看版本当前操作系统发行版信息 cat /etc/redhat-release
[root@VM_0_2_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
2.编辑配置文件。vim /etc/ssh/sshd_config。去掉注释,并修改为新的端口号,保存并退出
[root@VM_0_2_centos ~]# vim /etc/ssh/sshd_config
17 #Port 22 #默认是打开22端口
18 Port 9527 #新增自己自定义端口
3.在防火墙上放开自定义端口。 #iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 9527 -j ACCEPT
#iptables-save #保存iptables规则
[root@VM_0_2_centos ~]# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 9527 -j ACCEPT
[root@VM_0_2_centos ~]# iptables-save
[root@VM_0_2_centos ~]# iptables -nL --line-number
5.重启sshd服务。systemctl restart sshd。断开连接后,需要重新填写新的ssh端口号
[root@VM_0_2_centos ~]# systemctl restart sshd
[root@VM_0_2_centos ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 511 127.0.0.1:9000 *:*
LISTEN 0 128 *:111 *:*
LISTEN 0 511 *:80 *:*
LISTEN 0 128 *:9527 *:*
LISTEN 0 90 :::3306 :::*
LISTEN 0 128 :::111 :::*
6.xshell测试看是否能正常连接