[linux] ssh connection failed. (SELinux sshd firewalld)
Connecting to 172.17.11.147:22...
Could not connect to '172.17.11.147' (port 22): Connection failed.
Type `help' to learn how to use Xshell prompt.
Xshell:\>
先關掉防火牆重啟看看
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
出现这种情况的原因:
1.服务器端防火墙关闭了22端口,没有开启ssh服务;
2.没有安装ssh;
解决原因1:使用netstat,查看是否启动shh服务;
开启ssh服务:service sshd start
关闭ssh服务:service sshd stop
重启ssh服务:servcie sshd restart
SSH服务开机自动启动:chkconfig sshd on
取消开机自启动:chkconfig sshd off
开启服务后,检查服务状态:service sshd status
解决原因2:安装ssh:
yum install openssh-server
沒用
service ssh status
sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2016-05-05 03:30:48 UTC; 2s ago
Process: 10938 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 10944 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
Main PID: 10944 (code=exited, status=255)
May 05 03:30:48 ixnetwork-uk1 systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
May 05 03:30:48 ixnetwork-uk1 systemd[1]: Unit sshd.service entered failed state.
SELinux
yum provides /usr/sbin/semanage
yum -y install policycoreutils-python
semanage port -l | grep ssh
只允許port 22
去修改ssd_config port 然後新增規則
永久性的關掉 selinux
$ sudo vi /etc/sysconfig/selinux
找到
SELINUX=enforcing
然後修改為
SELINUX=disabled
要重新開機 reboot / restart 後才會套用
SELINUX=enforcing
然後修改為
SELINUX=disabled
要重新開機 reboot / restart 後才會套用
終於成功了QQ
留言
張貼留言