红联Linux门户
Linux帮助

Putty连接Linux提示timed out的解决办法

发布时间:2014-12-21 09:43:38来源:linux网站作者:yeyuan

先说下遇到的相关情况吧

在使用putty连接Ubuntu的时候,提示:Connection error : Connection timed out

意思是连接超时了!

后来我在网上查了下说是之前安装的ssh协议 重启之后,ssh服务没有启动

好吧,启动下ssh服务  service sshd start 或者是 /etc/init.d/ssh start


启动之后,发现了这个提示

Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key

这个意思我也不太懂,可能是两个文件不存在吧

然后在网上搜索了下,使用以下的命令进行重建下这两个文件

在终端中输入:ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key重新建立ssh_host_dsa_key文件


以下是返回信息

Generating public/private dsa key pair.

Enter passphrase (empty for no passphrase):(直接回车)

Enter same passphrase again:

Your identification has been saved in /etc/ssh/ssh_host_dsa_key.

Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.

The key fingerprint is:

xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx root@localhost.localdomain


在终端中输入:ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key重新建立ssh_host_rsa_key文件

以下是返回信息

Generating public/private rkey pair.

Enter passphrase (empty for no passphrase):(直接回车)

Enter same passphrase again:

Your identification has been saved in /etc/ssh/ssh_host_rsa_key.

Your public key has been saved in /etc/ssh/ssh_host_dsa_rey.pub.

root@localhost.localdomain


注意:上面的两条命令,在普通用户下不起作用,需要使用root权限

而默认情况下root是禁用的。可以使用下面的命令来启用root帐号

在普通用户的终端命令行下面输入 sudo passwd root (回车)  输入两次密码确认下

最后,再使用上面启动ssh服务的方法,启动下就ok了。