ssh 登錄出現的幾種錯誤以及解決辦法


首先、確保server端的ssh服務是開的(service shhd start)

然后在client端輸入: ssh usrname@serverip (遠程登錄)

scp filename usrname@serverip:/URL (遠程傳輸)

 

常出現的問題:

 

問題一

ssh登錄的時候鏈接端口失敗

提示(1):

# ssh 192.168.***.**

ssh: connect to host 192.168.***.** port 22: No route to host

這由於server端沒有開機或是網絡不通(這個原因很多,最簡單的是網線沒有插。還有就是可能會是網卡down了等)如果是網卡down了ifup相應的網卡再試試

 

提示(2):

# ssh zhou@192.168.***.**

ssh: connect to host 192.168.***.** port 22: Connection refused

這是由於對方server的ssh服務沒有開。這個server端開啟服務即可。 

如何開啟ssh服務呢?

首先確保要登錄的主機安裝了openssh-client(ubuntu有默認安裝,如果沒有則sudo apt-get install openssh-client),如果要使本機開放SSH服務就需要安裝 openssh-server sudo apt-get install openssh-server
   然后確認sshserver是否啟動了:
   ps -e |grep ssh
如果看到sshd那說明ssh-server已經啟動了。
如果沒有則可以這樣啟動:sudo /etc/init.d/ssh start
ssh-server配置文件位於/ etc/ssh/sshd_config,在這里可以定義SSH的服務端口,默認端口是22,你可以自己定義成其他端口號,如222。
然后重啟SSH服務:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
然后使用以下方式登陸SSH:
ssh zhou@192.168.***.** zhou為192.168.***.**機器上的用戶,需要輸入密碼。
斷開連接:exit

 

問題二、

ssh到server上的時候密碼是對的但是報如下信息:

# ssh 192.168.***.**

root@192.168.***.**'s password:

Permission denied, please try again.

 

這個是由於如果不輸入用戶名的時候默認的是root用戶,但是安全期間ssh服務默認沒有開root用戶的ssh權限

 

解決方法:

 

要修改root的ssh權限,即修改 /etc/ssh/sshd_config文件中

PermitRootLogin no 改為 PermitRootLogin yes

 

問題三

登錄是出現如下提示:

ssh root@192.168.***.**

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

76:fb:b3:70:14:48:19:d6:29:f9:ba:42:46:be:fb:77.

Please contact your system administrator.

Add correct host key in /home/fante/.ssh/known_hosts to get rid of this

message.

Offending key in /home/fante/.ssh/known_hosts:68

RSA host key for 192.168.***.** has changed and you have requested strict checking.

Host key verification failed.

 

server端密碼或是其他發生改變的時候。

解決方法一般就需要刪除~/.ssh/known_hosts的東西,然后再登錄即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM