1. 程式人生 > >putty 連線linux失敗---解決方案

putty 連線linux失敗---解決方案

在VMware中安裝Ubuntu之後,主機可以ping通虛擬機器,想用putty來連線,結果返回: Authentication refused。

如下為解決方案:

  1.在Ubuntu上檢視ssh服務是否開啟, ps -ef|grep ssh

  2.發現沒有開啟ssh,試圖開啟ssh, service ssh start(無法開啟ssh,因為沒有安裝ssh server 和 client)

  3.獲取ssh server和client 安裝包,apt update(返回很多404錯誤,說明有很多網址無法開啟)

  4.在網路上搜尋可用的源列表(source.list 位置為:/etc/apt/sources.list),例如163的源列表

      
deb http://mirrors.163.com/ubuntu/ quantal main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ quantal main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ quantal-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ quantal-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ quantal-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ quantal-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ quantal-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ quantal-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ quantal-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ quantal-updates universe main multiverse restricted
   為原來的sources.list做備份,然後更新源列表,做 update(apt update),仍然發現很多404錯誤(這是因為源列 表的目錄已經更改,即quantal目錄已經不存在)

,而lucid目錄存在(如下圖所示),並且有與quantal對應的檔案和目錄,將source.list中quantal全部替換為lucid。

   6.做update(apt update)

   7.安裝ssh server和client, sudo apt-get install openssh-server;sudo apt-get install openssh-client

   8.開啟ssh服務, etc/init.d/ssh start

   9.檢視ssh服務狀態  ps -ef|grep ssh,發現程序已起

  10.putty 連線Ubuntu成功