2012-01-06 112 views
0

我已經安裝並正在運行ssh。我跑了sudo chmod -R 777 /var並停止工作。我更改了sudo chmod -R 700 /var的權限,但這並沒有讓它再次運行。SSH到本地主機顯示「由遠程主機關閉連接」

當我做ssh -v localhost我得到這樣的輸出:

[email protected]:/$ ssh -v localhost 
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010 
debug1: Connecting to localhost [127.0.0.1] port 22. 
debug1: Connection established. 
debug1: identity file /home/rajat/.ssh/id_rsa type -1 
debug1: identity file /home/rajat/.ssh/id_rsa-cert type -1 
debug1: identity file /home/rajat/.ssh/id_dsa type -1 
debug1: identity file /home/rajat/.ssh/id_dsa-cert type -1 
debug1: identity file /home/rajat/.ssh/id_ecdsa type -1 
debug1: identity file /home/rajat/.ssh/id_ecdsa-cert type -1 
ssh_exchange_identification: Connection closed by remote host 
[email protected]:/$ 
+0

獲得的經驗教訓:不要那麼血腥。爲什麼在地球上搞亂'/ var'的權限不會破壞事情,你怎麼覺得把它們搞亂會有所幫助? – tripleee 2012-01-30 21:39:05

回答

4

OpenSSH是非常挑剔的,當涉及到的文件和目錄的權限和所有權。至少在RHEL/CentOS上,它所接觸的/var下的唯一目錄是/var/empty/sshd目錄,如果UsePrivilegeSeparation設置爲yes,它將執行chroot

設置這在您的sshd_config文件:

UsePrivilegeSeparation no 

,並重新啓動sshd的,看看它是否工作。如果那樣做的話,那很可能是導致問題的/var/empty/sshd上的權限/所有權。

+1

嗯,你回覆得太晚了:(但是幸運的是我在一臺虛擬機(vmware)中工作,最後我把所有的工作都複製到了一個版本庫,然後在虛擬機上恢復一個快照,並執行'svn update'但因爲這是唯一的答案,所以我要標記它是正確的。 – prongs 2012-01-09 10:56:58

2

如果有人在嘗試連接到在VirtualBox上運行的Ubuntu VM時遇到類似的錯誤消息,請在網絡設置中將第二個網絡適配器設置爲「橋接」,並將「NAT」上的端口轉發設置爲22.

相關問題