VPS是3個人合租共用的,不知道誰操作了什麼導致SSH啟動失敗,一直連接不上剛開始以為系統壞了呢,後面通過VPS終端登陸上去發現SSH服務沒在運行,於是嘗試運行SSHD發現出現如下錯誤:
Starting sshd:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for ‘/etc/ssh/ssh_host_rsa_key’ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for ‘/etc/ssh/ssh_host_dsa_key’ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available — exiting.
[FAILED]
解決方法:
#chmod 600 sshd_config ssh_host_dsa_key ssh_host_key ssh_host_rsa_key
#chmod 620 moduli
#chmod 644 ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub
#service sshd start
再次出現如下錯誤:
[root@bailongjun ssh]# service sshd restart
Stopping sshd: [FAILED]
Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.
[FAILED]
在終端上直接登錄,問題顯示如下:
/var/empty/sshd must be owned by root and not group or world-writable.
問題:
Linux上的SSH無法啟動
報告/var/empty/sshd must be owned by root and not group or world-writable.
解決辦法:
首先通過物理終端進入到linux上,手工檢查ssh發現沒運行
-bash-2.05b# /etc/init.d/sshd status
sshd is stopped
手工啟動服務,發現報告權限錯誤。
-bash-2.05b# /etc/init.d/sshd start
Starting sshd:/var/empty/sshd must be owned by root and not group or world-writable.
[FAILED]
-bash-2.05b#
使用rpm -V 命令可檢查到ssh的軟件包正常,但某個目錄的屬主錯誤。
-bash-2.05b# rpm -V openssh-server
S.5….. c /etc/ssh/sshd_config
…..U.. /var/empty/sshd
-bash-2.05b#
經查看發現這個目錄的屬主不是root,所以啟動ssh報錯
-bash-2.05b# ls -ld /var/empty/sshd/
d–x–x–x 2 vu00106 root 1024 Feb 2 2005 /var/empty/sshd/
-bash-2.05b#
修改為root屬主,啟動成功
-bash-2.05b# chown root /var/empty/sshd/
-bash-2.05b# /etc/init.d/sshd start
Starting sshd: [ OK ]
-bash-2.05b#
至此問題修復。
另外,還可以嘗試:
這個是權限的問題
可采取以下兩步解決
chown -R root.root /var/empty/sshd
chmod 744 /var/empty/sshd
service sshd restart
就可以解決上述的問題。