上次遇到的问题,在我修改了sshd的监听端口后,我进行service sshd restart ,而后从新打开一个ssh连接,是能够当即连接上sshd的,并且netstat也能够查到新的端口。linux
后面有一次我进行替换端口,而后systemctl restart sshd ,而后统一的连接操做发现都连接不上,而且我已经在firewalld中开了规则,我netstat也查不到ssh端口。运维
下面是systemctl status sshd 后的结果dom
以前作运维都是现场修改端口,或者也是当时没遇到问题,接着我在我虚拟机上进行了同样得操做ssh
重启服务,后查看服务状态spa
● 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.
可是此次一直停留在activating状态,在屡次无果状态后,我选择了远程重启电脑,结果卧槽,又能够了。。。。。rest
后续遇到的问题,我配置文件修改了 Port 22,Port 8022两个端口,22得成功,可是code
这样一看就是selinux的问题,通常正式环境selinux也是关闭了得,因此我关闭了selinux,而后重启服务就成功了server
关闭selinuxblog
查看SELinux状态: 一、/usr/sbin/sestatus -v ##若是SELinux status参数为enabled即为开启状态 SELinux status: enabled 二、getenforce ##也能够用这个命令检查 关闭SELinux: 一、临时关闭(不用重启机器): setenforce 0 ##设置SELinux 成为permissive模式 ##setenforce 1 设置SELinux 成为enforcing模式 二、修改配置文件须要重启机器: 修改/etc/selinux/config 文件 将SELINUX=enforcing改成SELINUX=disabled 重启机器便可