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
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAjM2EzLcd3LcJzLcJzdllmVldWYtl2Pn5GcuUWM0kTO2MTMxQGZ5kDMjBTN2YTMiBzYmZ2N1YDOxIWOvwlN1ATM1cTMtUGall3LcVmdhNXLwRHdo9CXt92YucWbpRWdvx2Yx5yazF2Lc9CX6MHc0RHaiojIsJye.png)
表示給出的提示很坑爹,完全不知道哪裡出錯了。
經過艱難的百度,可能是SELINUX啟用了,并且SELINUX允許的sshd-port跟設定的port不比對造成的.
1. 檢視SeLinux設定的ssh端口
# semanage port -l | grep ssh
發現端口22222和22是允許被使用的
2.檢視 ssh設定的端口
# vi /etc/ssh/sshd_config
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
可以看到,似乎是sftp組的設定參數似乎有問題
# vi /etc/ssh/sshd_config
使用 : set number顯示行号. 找到第147行
原來是ForceCommand 寫錯啦!趕緊改對.....
啟動成功!!!!