• 解决 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

  • 相关阅读:
    css3360度旋转动画
    PAT 1084 外观数列(20)(代码+思路+推荐测试用例)
    PAT 1083 是否存在相等的差(20)(代码+思路)
    PAT 1082 射击比赛(20)(代码+思路)
    PAT 1079 延迟的回文数(代码+思路)
    PAT 1078 字符串压缩与解压(20)(代码+思路)
    PAT 1077 互评成绩计算(20)(代码+思路)
    PAT 1073 多选题常见计分法(20)(代码+思路)
    PAT 1072 开学寄语(20)(代码+思路)
    PAT 1069 微博转发抽奖(20)(代码+思路+测试点4)
  • 原文地址:https://www.cnblogs.com/gtarcoder/p/4757657.html
Copyright © 2020-2023  润新知