首先,確保server端的ssh服務是開的(service shhd start)linux
而後在client端輸入: ssh usrname@serverip (遠程登陸)ubuntu
scp filename usrname@serverip:/URL (遠程傳輸)vim
常出現的問題:安全
1.端口失效網絡
# ssh 192.168.***.**ssh
ssh: connect to host 192.168.***.** port 22: No route to hostui
這因爲server端沒有開機或是網絡不通(這個緣由不少,最簡單的是網線沒有插。還有就是可能會是網卡down了等)若是是網卡down了ifup相應的網卡再試試this
2.linux的ssh服務沒有開啓spa
首先確保要登陸的主機安裝了openssh-clientrest
(ubuntu有默認安裝,若是沒有則輸入安裝命令)
sudo apt-get install openssh-client
若是要使本機開放SSH服務就須要安裝 openssh-server
sudo apt-get install openssh-server
server安裝過程當中可能會出現問題以下:
Reading package lists… Done Building dependency tree Reading state information… Done Package openssh-server is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package openssh-server has no installation candidate
從新運行如下的代碼
sudo apt-get update sudo apt-get upgrade 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
3.
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
vim /etc/ssh/sshd_config
找到
# Authentication: LoginGraceTime 120 PermitRootLogin prohibit-password StrictModes yes
改爲
# Authentication: LoginGraceTime 120 PermitRootLogin yes StrictModes yes
而後重啓服務
/etc/init.d/ssh restart
4.
登陸是出現以下提示:
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的東西,而後再登陸便可。