SSH 到本地主机显示"Connection closed by remote host"



我安装了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:/$ 

OpenSSH在文件和目录权限和所有权方面非常挑剔。它在/var下唯一接触到的目录是/var/empty/sshd目录,至少在RHEL/CNTOS上是这样,如果UsePrivilegeSeparation设置为yes,它会对其执行chroot操作。

sshd_config文件中设置:

UsePrivilegeSeparation no

然后重新启动sshd,看看它是否有效。如果是这样的话,很可能是/var/empty/sshd上的权限/所有权造成了问题。

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

相关内容

最新更新