centos修改端口出现Failed to start OpenSSH server daemon 启动报错和-xe报错的解决方法
修改SSH端口:
# vi /etc/ssh/sshd_config
里面找port 22,在前面加上#,去掉注释,然后把22改成你想要的端口。
#port 22
建议去掉注释之前,先增加你需要的端口,比如:12345端口,生效后在删除22端口,以防止修改后,操作错误进不去系统。
Port 22
Port 12345
在防火墙中添加改SSH端口。
对应的命令和教程查看:https://www.yidc.net/archives/24。
然后重启sshd服务 ,命令如下:
查看状态:
systemctl status sshd.service
启动服务:
systemctl start sshd.service
重启服务:
systemctl restart sshd.service
开机自启:
systemctl enable sshd.service
一、如果执行重启命令后提示 -xe 报错:
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
然后在执行
# systemctl status sshd.service
得到的反馈:
● 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 2019-12-08 08:08:31 EST; 26s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 18904 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
Main PID: 18904 (code=exited, status=255)
Dec 08 08:08:31 DC6200-17 systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
Dec 08 08:08:31 DC6200-17 systemd[1]: Failed to start OpenSSH server daemon.
Dec 08 08:08:31 DC6200-17 systemd[1]: Unit sshd.service entered failed state.
Dec 08 08:08:31 DC6200-17 systemd[1]: sshd.service failed.
二、如上可见: Failed to start OpenSSH server daemon 红色报错。
然后在执行: # journalctl -xe
执行后,会出现一堆没用的提示。
最后在执行: #setenforce 0
即,关闭selinux,然后,一切正常。
最后执行重启命令:# systemctl restart sshd.service
自此大工告成。
原创文章,作者:kinpo, k,如若转载,请注明出处:https://www.yidc.net/archives/70