zoukankan      html  css  js  c++  java
  • 解决 ssh 登录到ubuntu server 慢的问题

      最近在服务器上使用ubuntu系统,服务器上开启sshd服务,在客户端处使用ssh登录到服务器的时候出现卡顿的现象。

    在网上搜索了解决方案,主要是:

    1. 修改服务器的 /etc/ssh/sshd_config

    添加  UseDNS no

    2. 修改服务器的 /etc/ssh/ssh_config

    添加 GSSAPIAuthentication no

    然后重新启动ssh 服务, /etc/init.d/ssh restart

      尝试了以上方法发现都不起作用,于是使用 ssh -v root@192.168.1.2 进行ssh登录过程跟踪,发现如下记录:

     
    debug1: Authentications that can continue: publickey,password
    debug1: Next authentication method: publickey
    debug1: Trying private key: /home/jason/.ssh/id_rsa
    debug1: Trying private key: /home/jason/.ssh/id_dsa
    debug1: Trying private key: /home/jason/.ssh/id_ecdsa
    debug1: Trying private key: /home/jason/.ssh/id_ed25519
    debug1: Next authentication method: password
    root@192.168.1.2's password: 
    debug1: Authentication succeeded (password).
    Authenticated to 192.168.1.2 ([192.168.1.2]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LC_PAPER = zh_CN.UTF-8
    debug1: Sending env LC_ADDRESS = zh_CN.UTF-8
    debug1: Sending env LC_MONETARY = zh_CN.UTF-8
    debug1: Sending env LC_NUMERIC = zh_CN.UTF-8
    debug1: Sending env LC_TELEPHONE = zh_CN.UTF-8
    debug1: Sending env LC_IDENTIFICATION = zh_CN.UTF-8
    debug1: Sending env LANG = en_US.UTF-8
    debug1: Sending env LC_MEASUREMENT = zh_CN.UTF-8
    debug1: Sending env LC_TIME = zh_CN.UTF-8
    debug1: Sending env LC_NAME = zh_CN.UTF-8
    

    发现在  debug1: Entering interactive session. 的地方会卡顿几十秒。

    登录成功以后,系统给出登陆后的信息:

    Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.0.35-2508-g54750ff armv7l)
    
     * Documentation:  https://help.ubuntu.com/
    
    495 packages can be updated.
    296 updates are security updates.
    
    New release '12.10' available.
    Run 'do-release-upgrade' to upgrade to it.
    
    Last login: Thu Jan  1 01:05:10 1970 from 192.168.1.106
    

    上面的内容在其它版本中为/etc/motd中的内容,但ubuntu是动态生成该内容,生成脚本在/etc/update-motd.d目录下,查看脚本可以是联网检测系统更新等情况。

    修改/etc/pam.d/sshd/etc/pam.d/login文件中的有pam_motd.so的行注释掉

    #session    optional     pam_motd.so  motd=/run/motd.dynamic noupdate
    #session    optional     pam_motd.so # [1]
    

    再次ssh,这次没有了上面的update等信息了,但ssh也不卡顿了。

    参考:http://yaxin-cn.github.io/Linux/solve-ssh-slow-to-ubuntu.html

  • 相关阅读:
    Binary Tree
    (并查集..含小总结)A
    (超简单并查集)POJ2524 Ubiquitous Religions(8.4.4)
    OpenSees开发(一)windows 上编译opensees (使用vs2005)
    vector的push_back对于拷贝构造和赋值操作的调用
    一个指针的引用引发的血案
    MFC中由左键单击模拟左键双击引起的问题
    CLAPACK动态调用
    SVN部署(远程)客户端篇
    SVN部署(本地)
  • 原文地址:https://www.cnblogs.com/gtarcoder/p/4757657.html
Copyright © 2011-2022 走看看