zoukankan      html  css  js  c++  java
  • 解决ssh连接慢(有时候等半分钟才出现密码输入提示)的方法

    经常通过ssh 或者 scp 连接一堆远程主机,同样是 Linux 主机,其中一些创建 ssh 连接速度特别慢,连接建立之后执行操作速度却很正常,看来应该不是网络原因。解决的方法是通过ssh 的-v参数来查看调试信息的:

    用 ssh -v 来查看详细的连接建立过程,马上用一台建立连接很慢的主机试了一下,在一大堆输出信息中发现在这里停留最久:

    debug1: Authentications that can continue: publickey,gssapi-with-mic,password
    debug1: Next authentication method: gssapi-with-mic
    debug1: Unspecified GSS failure. Minor code may provide more information
    No credentials cache found
    
    debug1: Unspecified GSS failure. Minor code may provide more information
    No credentials cache found
    
    debug1: Unspecified GSS failure. Minor code may provide more information
    
    debug1: Next authentication method: publickey
    

    原来是因为尝试了个没有意义而且会失败的 gssapi-with-mic 认证方式浪费了时间,打开(远程服务器) /etc/ssh/ssh_config 把里面的 GSSAPIAuthentication yes 改成 no 关掉它,即可让 ssh 直接尝试美妙的 publickey 认证方式。

    禁用 GSSAPIAuthentication 前后建立 ssh 连接时间的对比:

    view plaincopy to clipboardprint?
    root@server:~$ time ssh root@192.168.10.1 exit

    real 0m18.488s
    user 0m0.004s
    sys 0m0.008s
    root@server:~$ time ssh root@192.168.10.1 exit

    real 0m3.531s
    user 0m0.016s
    sys 0m0.000s

    无论你是在服务器上或本地机器上关闭这个都是有效的.因为我们的服务器有专人管理,没有root帐号.所以我在本机的/etc/ssh/ssh_config中加入了

    GSSAPIAuthentication no 

    就可以解决问题了

  • 相关阅读:
    [BZOJ1015] [JSOI2008]星球大战starwar
    [BZOJ2321,LuoguP1861]星(之)器
    Google Search Operators
    Python blockchain
    CCAE词频表(转)
    python小技巧(转)
    Python著名的lib和开发框架(均为转载)
    Yarn取代job/task tracker
    hadoop 2.73‘s four xml
    HDFS NN,SNN,BN和HA
  • 原文地址:https://www.cnblogs.com/york-hust/p/3926687.html
Copyright © 2011-2022 走看看