Fork me on GitHub
ssh远程无法连接VM中的Ubuntu问题

Ubuntu ssh远程无法连接问题

1、 检查sudo ps -e|grep ssh  查看是否有ssh进程服务,如果没有的话,需要下载安装  sudo apt-get install openssh-server

 

2、

 

修改/etc/ssh/sshd-config文件.

 

 

 

将其中的PermitRootLogin no修改为yes

 

 

 

PubkeyAuthentication yes修改为no

 

 

 

AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉,

 

 

 

PasswordAuthentication no修改为yes就可以了。

 

 

 

 

 

 

 

 

 

3、采用ubuntu系统客户端去连接的时候,需要设置root密码 命令: sudo passwd root      根据提示设置密码两次!

 

 

 

 

 

4、ssh client 报 algorithm negotiation failed的解决方法之一

 

修改sshd的配置文件 /etc/ssh/sshd_config

在配置文件中添加:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

重启sshd服务后,即可正常连接。

导致此问题的原因是ssh升级后,为了安全,默认不再采用原来一些加密算法,我们手工添加进去即可。

解决Ubuntu 16.04 SSH 无法远程登录问题

方法/步骤

 
  1.  

     

    1.  安装 open ssh:

     

    sudo apt-get install openssh-server

     

  2. 2

     

    2. 修改root密码

     

    #sudo passwd root

     

  3. 3

     

    3. 辑配置文件,允许以 root 用户通过 ssh 登录:

     

    sudo vi /etc/ssh/sshd_config

     

    找到:PermitRootLogin prohibit-password禁用

     

    添加:PermitRootLogin yes

     

    sudo service ssh restart

    OK,正常登录!!!

    在用windows SSH客户端连接的时候会出现以下错误:

    这可能是由于客户端算法与服务器端不匹配造成的,下面是解决方法。

     

    首先,我们用root登录到ubuntu服务器

    $: sudo su

    输入密码之后登陆root用户,

    用vim打开/etc/ssh/sshd_config 文件,在文件末尾添加以下内容:

     

     Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
    
    
    
     MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
    
    
    
     KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org
    除了第三条的最后一个是灰色加紫色,其他的是蓝色,如果是灰色说明不对!(vim 中颜色显示)

     

    再将此文件中PermitRootLogin 后面改为yes,允许root用户身份登录。

    然后,保存退出!

    那么必须给root用户设置密码:

    # passwd

    (输入密码)

    重启ssh服务

    # service ssh reload  // 重新加载配置文件

    # service ssh restart  //重启ssh服务

    再次用ssh连接,已经可以了。

https://jingyan.baidu.com/article/9c69d48fb9fd7b13c8024e6b.html

https://jingyan.baidu.com/article/6079ad0e97278828ff86dbb7.html

 

posted on 2017-06-09 07:10  HackerVirus  阅读(811)  评论(0编辑  收藏  举报