1. ssh:Connection refused

1) ssh 120.0.0.11 Connection refused

root@node2:/opt/zq# ssh ubuntu@120.0.0.11
ssh: connect to host 120.0.0.11 port 22: Connection refused
2. ubuntu虚拟机安装openssh-server

1) apt-get安装,如果提示无法安装,找不到源,那么apt-get update

apt-get install openssh-server      

2) 如果,更新源还是不可以,则修改源路径:

vi /etc/apt/sources.list

修改如下:

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
3. WARNING: IDENTIFICATION HAS CHANGED!

1) ssh远程无法登陆,提示验证。首先确保登录用户为root权限。

root@node2:/opt/zq# ssh 120.0.0.11
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
a1:d1:fe:08:87:87:e0:0f:64:d1:fa:0b:7a:28:09:78.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:37
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R 120.0.0.11
ECDSA host key for 120.0.0.11 has changed and you have requested strict checking.
Host key verification failed.

2) 开启ssh远程权限

 vi /etc/ssh/ssh_config 

ubuntu版本不同该文件有所区别:
http://blog.csdn.net/qiqishuang/article/details/51547884
修改如下:

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
   PasswordAuthentication no
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

3) 依然无法登陆,则有以下几种解决方案:

  • Just delete the known_hosts file If you have only used one ssh server
mv /root/.ssh/known_hosts /tmp
4. ssh正确登陆姿势

1) 不正确姿势:ssh 120.0.0.11

root@node2:/opt/zq# ssh 120.0.0.11
The authenticity of host '120.0.0.11 (120.0.0.11)' can't be established.
ECDSA key fingerprint is a1:d1:fe:08:87:87:e0:0f:64:d1:fa:0b:7a:28:09:78.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '120.0.0.11' (ECDSA) to the list of known hosts.
root@120.0.0.11's password: 
Permission denied, please try again.
root@120.0.0.11's password: 
Permission denied, please try again.
root@120.0.0.11's password: 
Permission denied (publickey,password).

2) 正确姿势:ssh ubuntu@120.0.0.11

root@node2:/opt/zq# ssh ubuntu@120.0.0.11
ubuntu@120.0.0.11's password: 
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue May 31 02:59:19 EDT 2016

  System load: 0.22              Memory usage: 3%   Processes:       83
  Usage of /:  5.0% of 17.34GB   Swap usage:   0%   Users logged in: 0

  Graph this data and manage this system at:
    https://landscape.canonical.com/

0 packages can be updated.
0 updates are security updates.

Last login: Tue May 31 02:59:19 2016
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐