分享

sshd修改端口后几次启动失败

 WindySky 2017-07-19

上次遇到的问题,在我修改了sshd的监听端口后,我进行service sshd restart ,然后重新打开一个ssh链接,是可以立即链接上sshd的,而且netstat也可以查到新的端口。

后面有一次我进行替换端口,然后systemctl restart sshd ,然后统一的链接操作发现都链接不上,并且我已经在firewalld中开了规则,我netstat也查不到ssh端口。

下面是systemctl status sshd 后的结果

sshd修改端口后几次启动失败

之前做运维都是现场修改端口,或者也是当时没遇到问题,接着我在我虚拟机上进行了一样得操作

sshd修改端口后几次启动失败

重启服务,后查看服务状态
sshd修改端口后几次启动失败

code
1
2
3
4
5
6
7
8
9
10
11
12
13
<code>● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2017-04-09 19:42:30 CST; 786ms ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 30040 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
 Main PID: 30040 (code=exited, status=255)
Apr 09 19:42:30 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
Apr 09 19:42:30 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
Apr 09 19:42:30 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
Apr 09 19:42:30 localhost.localdomain systemd[1]: sshd.service failed.
</code>

但是这次一直停留在activating状态,在多次无果状态后,我选择了远程重启电脑,结果卧槽,又可以了。。。。。

后续遇到的问题,我配置文件修改了 Port 22,Port 8022两个端口,22得成功,但是

sshd修改端口后几次启动失败

这样一看就是selinux的问题,一般正式环境selinux也是关闭了得,所以我关闭了selinux,然后重启服务就成功了

关闭selinux

code
1
2
3
4
5
6
7
8
9
10
11
12
<code>查看SELinux状态:
1、/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态
SELinux status:                 enabled
2、getenforce                 ##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0                  ##设置SELinux 成为permissive模式
                              ##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可</code>

以上就是对sshd修改端口后几次启动失败的相关介绍,希望对您学习linux有所帮助,感谢您关注织梦者!

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多