天天看點

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

CentOS7啟動SSH服務報:

Job for ssh.service failed because the control process exited with error codesee systemctl status ssh.service and journalctl -xe for details.

然後按照提示輸入: systemctl status sshd.service

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

表示給出的提示很坑爹,完全不知道哪裡出錯了。

經過艱難的百度,可能是SELINUX啟用了,并且SELINUX允許的sshd-port跟設定的port不比對造成的.

1. 檢視SeLinux設定的ssh端口

# semanage port -l | grep ssh

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

發現端口22222和22是允許被使用的

2.檢視 ssh設定的端口

# vi /etc/ssh/sshd_config

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

ssh使用的是預設端口22,與selinux是比對的。不是這個錯。繼續百度......

終于在ubuntu社群看到一篇文章:

run sudo /usr/sbin/sshd -T to see what is wrong with the service and why does it fail.

# /usr/sbin/sshd -T

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

可以看到,似乎是sftp組的設定參數似乎有問題

# vi /etc/ssh/sshd_config

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

使用 : set number顯示行号. 找到第147行

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

原來是ForceCommand 寫錯啦!趕緊改對.....

CentOS7啟動SSH服務報:Job for ssh.service failed because the control process exited with error code.......

啟動成功!!!!