先說下遇到的相關情況吧
在使用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 [email protected]
在終端中輸入: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權限
而默認情況下root是禁用的。可以使用下面的命令來啟用root帳號
在普通用戶的終端命令行下面輸入 sudo passwd root (回車) 輸入兩次密碼確認下
最後,再使用上面啟動ssh服務的方法,啟動下就ok了