想用Xshell连接Centos7服务器,但发现能够ping通却无法连接。
按照网上的博客分别试了以下但无效果:
1:防火墙开关
2:防火墙端口开关
3:ssh/sshd服务的启动或未安装
4:端口的占用情况
5:网卡设置为静态/桥接模式
试了很久发现毫无用处。
然后解决方法如下:
cd /etc/ssh/
ll查看sshd配置文件夹。
vim sshd_config
发现如下字符:
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#change port yzy 20187111556 /#port:22
Port 15678
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
尝试连接端口15678,成功了。