ssh到localhost显示“连接被远程主机关闭”

时间:2012-01-06 05:16:19

标签: ubuntu ssh sshd

我已经安装并运行了ssh。我跑了sudo chmod -R 777 /var,它就停止了工作。我使用sudo chmod -R 700 /var更改了权限,但这并没有让它再次运行。

当我ssh -v localhost时,我得到了这个输出:

rajat@ubuntu:/$ 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
rajat@ubuntu:/$ 

2 个答案:

答案 0 :(得分:4)

OpenSSH在文件和目录权限和所有权方面非常挑剔。它所触及的/var下唯一的目录,至少在RHEL / CentOS上,是/var/empty/sshd目录,如果chroot设置为是,它会UsePrivilegeSeparation

sshd_config文件中设置此内容:

UsePrivilegeSeparation no

然后重新启动sshd,看看它是否有效。如果这样做,则/var/empty/sshd上的权限/所有权可能会导致问题。

答案 1 :(得分:2)

如果有人在尝试连接到VirtualBox上运行的Ubuntu VM时遇到类似的错误消息,请在网络设置中将第二个网络适配器设置为“桥接”,并将“NAT”上的端口转发设置为22.

相关问题