我安装了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。