远程连接不了服务器时,可能原因有:sshd服务未开启、防火墙阻挡、端口未开放或者被占用、selinux阻挡。这里介绍一下常见原因及处理办法。
1, sshd service is not open
#service sshd status (see sshd state)
#service Start sshd (sshd service is turned on)
#service Network restart (restart network service)
is set to boot from the start to avoid each the same reason.
#chkconfig sshd on
can then view the status sshd run levels:
#chkconfig --list sshd
sshd 0: Close 1: Close 2: Enabled 3: Enable 4: Enable 5: 6 Enable: Off
2、防火墙阻挡
#service iptables stop(关闭防火墙再次登录远程服务)
相关命令如下
#iptables -L (查看防火墙状态)
#service iptables start(开启防火墙)
3, the port is occupied or not open
to view sshd configuration port number (default port 22)
#cat / etc / SSH / sshd_config
#netstat -antlp | grep 22
开放端口
#vi /etc/sysconfig/iptables”,
添加一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2 -j ACCEPT
#service iptables restart(重启)
#service iptables status(显示正在生效的规则)
杀死进程
查看pid
#ps -aux
#kill -s 9 1827(9意味着终止、1827是pid)