可能是虚拟机没有安装openssh-server服务,安装一下apt-getinstallopenssh-server 发现仍然没有任何反应
手工启动服务,service sshd restart 报告sshd: unrecognized service
奇怪执行-bash-2.05b# /etc/init.d/sshd start,说没有这个目录,我用的是server版本10.24
查看是否启动了sshd:
ps -e |grep ssh
也有启动显示有sshd
确认ssh-server已经正常工作。
$ netstat -tlp
tcp6 0 0 *:ssh *:* LISTEN -
也已经工作。
测试ssh连接:
ssh localhost
提示连接不上:SSH problem - Read from socket failed: Connection reset by peer
最后搜索到解决方法:如上连接
如上所述,将文件改成如下权限即可:
It's because somehow the permissions of the files inside /etc/ssh
have changed... So change the permission of the files like the example given below:
use:
chmod 644 ssh_config
chmod 600 moduli
and so on...
Finally the file permissions should look like something like given below,
[root@hostname ssh]# ls -latr
total 172
-rw-r--r--. 1 root root 2047 Aug 12 2010 ssh_config
-rw-------. 1 root root 125811 Aug 12 2010 moduli
-rw-------. 1 root root 963 Mar 1 16:02 ssh_host_key
-rw-r--r--. 1 root root 627 Mar 1 16:02 ssh_host_key.pub
-rw-r--r--. 1 root root 382 Mar 1 16:02 ssh_host_rsa_key.pub
-rw-------. 1 root root 1675 Mar 1 16:02 ssh_host_rsa_key
-rw-r--r--. 1 root root 590 Mar 1 16:02 ssh_host_dsa_key.pub
-rw-------. 1 root root 668 Mar 1 16:02 ssh_host_dsa_key
-rw-------. 1 root root 3845 May 7 11:52 sshd_config
After changing the permissions try connecting from putty, should work fine..
以上文件在/etc/ssh目录
非常感谢这位同志。。
注:此问题比较怪异,之前都是可以连接的,突然就连接不上了。而且SecureCRT能连接到其他服务器。就是本机的虚拟机服务器连接不上。而且能ping同本机的虚拟机。所以怀疑本机安装的服务有问题。但是不知道为什么除了 问题,因为之前安装过的,一直都在用。。