经常通过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 

就可以解决问题了

最新文章

  1. CANopen学习——协议栈
  2. 去繁从简--简化Message和Signal设置
  3. Java白皮书的关键术语
  4. Elasticsearch增删改查 之 —— mget多文档查询
  5. Security » Authorization » 介绍
  6. iterm2相关配置
  7. POJ 1562 && ZOJ 1709 Oil Deposits(简单DFS)
  8. 【SQL语句】 - Ctrl+3 查询表属性的存储过程 [sp_select_talberowName]
  9. AngularJS进阶(三十八)上拉加载问题解决方法
  10. 【转】Windows Server 2008 R2下安装 .net framework3.5
  11. 《Linux内核设计与实现》读书笔记 18
  12. pandas网页操作基础
  13. C# DataGridView中单元格Cell改变事件
  14. MySQL专题 2 数据库优化 Slow Query log
  15. native方法
  16. Hadoop的分布式架构改进与应用
  17. Hadoop2.9下运行JAR包时System.out.println的输出日志
  18. [cqoi2012]交换棋子
  19. pip 代理设置,坑爹的代理继续
  20. Django之restframework2视图三部曲

热门文章

  1. tortoisegit 右键无图标
  2. The ECDSA host key for XXX has changed
  3. python 3使用binascii方法的报错解决
  4. C# chart控件基础使用
  5. bash shell 获取当前正在执行脚本的绝对路径
  6. Lucene底层原理和优化经验分享(1)-Lucene简介和索引原理
  7. 百度云盘下载插进-油猴Tampermonkey
  8. Linux默认日志含义
  9. STAF进行分布式脚本分发----实践篇
  10. java生成PDF,各种格式、样式、水印都有