http://blog.csdn.net/ablo_zhou/article/details/5074887

=============

现象:

在局域网内,能ping通目标机器,并且时延是微秒级。

用ssh连局域网内其他linux机器,会等待10-30秒才有提示输入密码。严重影响工作效率。

========================

客户端操作系统版本:

zhouhh@zhhofs:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"

========================

调试信息:

  1. zhouhh@zhhofs:~$ ssh -v 192.168.12.16
  2. OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug1: Applying options for *
  5. debug1: Connecting to 192.168.12.16 [192.168.12.16] port 22.
  6. debug1: Connection established.
  7. debug1: identity file /home/zhouhh/.ssh/identity type -1
  8. debug1: identity file /home/zhouhh/.ssh/id_rsa type -1
  9. debug1: identity file /home/zhouhh/.ssh/id_dsa type -1
  10. debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
  11. debug1: match: OpenSSH_4.3 pat OpenSSH_4*
  12. debug1: Enabling compatibility mode for protocol 2.0
  13. debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
  14. debug1: SSH2_MSG_KEXINIT sent
  15. debug1: SSH2_MSG_KEXINIT received
  16. debug1: kex: server->client aes128-cbc hmac-md5 none
  17. debug1: kex: client->server aes128-cbc hmac-md5 none
  18. debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
  19. debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
  20. debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
  21. debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
  22. debug1: Host '192.168.12.16' is known and matches the RSA host key.
  23. debug1: Found key in /home/zhouhh/.ssh/known_hosts:1
  24. debug1: ssh_rsa_verify: signature correct
  25. debug1: SSH2_MSG_NEWKEYS sent
  26. debug1: expecting SSH2_MSG_NEWKEYS
  27. debug1: SSH2_MSG_NEWKEYS received
  28. debug1: SSH2_MSG_SERVICE_REQUEST sent
  29. debug1: SSH2_MSG_SERVICE_ACCEPT received
  30. debug1: Authentications that can continue: publickey,gssapi-with-mic,password
  31. debug1: Next authentication method: gssapi-with-mic
  32. debug1: An invalid name was supplied
  33. Cannot determine realm for numeric host address
  34. debug1: An invalid name was supplied
  35. Cannot determine realm for numeric host address
  36. debug1: An invalid name was supplied
  37. debug1: Next authentication method: publickey
  38. debug1: Trying private key: /home/zhouhh/.ssh/identity
  39. debug1: Trying private key: /home/zhouhh/.ssh/id_rsa
  40. debug1: Trying private key: /home/zhouhh/.ssh/id_dsa
  41. debug1: Next authentication method: password
  42. zhouhh@192.168.12.16's password:
  43. debug1: Authentication succeeded (password).
  44. debug1: channel 0: new [client-session]
  45. debug1: Entering interactive session.
  46. debug1: Sending environment.
  47. debug1: Sending env LANG = zh_CN.UTF-8
  48. Last login: Fri Dec 25 13:35:04 2009 from 192.168.11.146

可以看到如下的错误信息:

debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address

事实上,正是从gssapi-with-mic这一行开始,开始耗时间。

====================

失败的尝试:

有人说是在目标机器中修改/etc/ssh/sshd_conf文件

将UseDNS 的缺省值由yes修改为no,并重启sshd。我试了,对这种情况不管用。但不排除对别的延迟情况管用。

====================

有效的解决办法:

1. 修改本地机器的hosts文件,将目标机器的IP和域名加上去。或者让本机的DNS 服务器能解析目标地址。

vi /etc/hosts

192.168.12.16  ourdev

其格式是“目标机器IP 目标机器名称”这种方法促效。没有延迟就连上了。不过如果给每台都加一个域名解析,挺辛苦的。但在windows下用putty或secure-crt时可以采用这种方法。

2.修改本机的客户端配置文件ssh_conf,注意,不是sshd_conf

vi /etc/ssh/ssh_conf

找到

GSSAPIAuthentication yes

改为

GSSAPIAuthentication no

保存。

再连目标机器,速度就飞快了。

GSSAPI ( Generic Security Services Application Programming Interface) 是一套类似Kerberos 5 的通用网络安全系统接口。该接口是对各种不同的客户端服务器安全机制的封装,以消除安全接口的不同,降低编程难度。但该接口在目标机器无域名解析时会有问题。我看到有人给ubuntu提交了相关bug, 说要将GSSAPIAuthentication的缺省值设为no,不知为何,ubuntu9.10的缺省值还是yes。

修改完毕,此时的连接调试数据变为了:

  1. zhouhh@zhhofs:~$ ssh -v 192.168.12.16
  2. OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug1: Applying options for *
  5. debug1: Connecting to 192.168.12.16 [192.168.12.16] port 22.
  6. debug1: Connection established.
  7. debug1: identity file /home/zhouhh/.ssh/identity type -1
  8. debug1: identity file /home/zhouhh/.ssh/id_rsa type -1
  9. debug1: identity file /home/zhouhh/.ssh/id_dsa type -1
  10. debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
  11. debug1: match: OpenSSH_4.3 pat OpenSSH_4*
  12. debug1: Enabling compatibility mode for protocol 2.0
  13. debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
  14. debug1: SSH2_MSG_KEXINIT sent
  15. debug1: SSH2_MSG_KEXINIT received
  16. debug1: kex: server->client aes128-cbc hmac-md5 none
  17. debug1: kex: client->server aes128-cbc hmac-md5 none
  18. debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
  19. debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
  20. debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
  21. debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
  22. debug1: Host '192.168.12.16' is known and matches the RSA host key.
  23. debug1: Found key in /home/zhouhh/.ssh/known_hosts:1
  24. debug1: ssh_rsa_verify: signature correct
  25. debug1: SSH2_MSG_NEWKEYS sent
  26. debug1: expecting SSH2_MSG_NEWKEYS
  27. debug1: SSH2_MSG_NEWKEYS received
  28. debug1: SSH2_MSG_SERVICE_REQUEST sent
  29. debug1: SSH2_MSG_SERVICE_ACCEPT received
  30. debug1: Authentications that can continue: publickey,gssapi-with-mic,password
  31. debug1: Next authentication method: publickey
  32. debug1: Trying private key: /home/zhouhh/.ssh/identity
  33. debug1: Trying private key: /home/zhouhh/.ssh/id_rsa
  34. debug1: Trying private key: /home/zhouhh/.ssh/id_dsa
  35. debug1: Next authentication method: password
  36. zhouhh@192.168.12.16's password:

ssh 连接很慢的解决办法的更多相关文章

  1. 关于 ssh 连接较慢的解决办法

    1. 概述 使用 ssh 软件连接 linux 时, 会碰到很慢的情况 2. 场景 概述 ssh 连接很慢 大概步骤 使用 xshell6 免费版, 连接 主机 一个小等待, 弹出 用户名 输入框 输 ...

  2. 配置BUG-Linux系统下ssh登陆很慢的解决办法

    很多的Linux用户发现连接上Linux服务器在输入用户名之后还要再等一下才能输入密码,时间过长了,现在小编与大家分享一下如何解决ssh登陆问题的问题,希望对您有所帮助 . 1.我们平时登陆Linux ...

  3. Linux系统下ssh登陆很慢的解决办法

    很多的Linux用户发现连接上Linux服务器在输入用户名之后还要再等一下才能输入密码,时间过长了,现在小白与大家分享一下如何解决ssh登陆问题的问题,希望对您有所帮助. 1.我们平时登陆Linux服 ...

  4. SecureCRT ssh连接linux操作系统(解决Ubutu密钥交换失败的问题)

    我们可以使用终端软件SecureCRT 去连接linux操作系统(该SecureCRT服务走端口22,协议是ssh(类似apache走http协议,端口80)),SSH 为 Secure Shell ...

  5. WCF服务运行一段时间后客户端无法连接WCF服务的解决办法 (转)

    WCF服务运行一段时间后客户端无法连接WCF服务的解决办法 (转) Windows Communication Foundation (WCF)是Microsoft为构建面向服务的应用提供的分布式通信 ...

  6. pip install 提示代理连接失败原因及解决办法

    # pip install 提示代理连接失败原因及解决办法 1. 错误提示 在公司电脑上安装Python的虚拟环境时输入命令: pip install virtualenv 系统提示以下异常信息: R ...

  7. Permission 0644 for .ssh/id_rsa Are Too Open 解决办法

    Permission 0644 for .ssh/id_rsa Are Too Open 解决办法 学习了:https://blog.csdn.net/muyimo/article/details/7 ...

  8. Xamarin中VS无法连接Mac系统的解决办法

    Xamarin中VS无法连接Mac系统的解决办法 按照以下步骤排查:(1)确认Mac系统中安装Xamarin.iOS开发必备的组件,如Mono.Xamarin.iOS.(2)将Windows和Mac下 ...

  9. WIN8.1的安装和打开"这台电脑"速度很慢的解决办法

    WIN8.1的安装和打开"这台电脑"速度很慢的解决办法 对于非服务器用的电脑,如果电脑的内存在2G或更高,首推的操作系统是 WINDOWS8.1 64位企业版,用了就知道,没有比这流畅懂事的操作系统. ...

随机推荐

  1. react拖拽(表格拖拽排序、普通拖拽排序以及树形拖拽排序)

    表格拖拽排序:组件地址:https://reactabular.js.org/#/drag-and-drop 拖动的排序是用React-DnD:React-DnD:http://react-dnd.g ...

  2. .NET/C# 使用反射注册事件

    使用反射,我们可以很容易地在运行时调用一些编译时无法确定的属性.方法等.那么如何注册事件呢? 本文将介绍如何使用反射注册事件. 本文内容 不使用反射 使用反射 安全地使用反射 参考资料 不使用反射 例 ...

  3. 线上服务器TCP被打满是啥情况

    从一个线上服务器警告谈谈backlog https://wangxiangnan.cc/?p=105 缘起 双十一如期而至,此时的我因为在处理客户的一个问题已经陷入了忙碌.突然,不断接到驻场实施发来的 ...

  4. windows常用DLL及作用

    Kernel.dll:内存,硬盘灯硬件管理的相关函数. gdi32.dll:图形显示相关函数(LoadImage,GetPixel,StretchBlt,Ellipse). user32.dll:wi ...

  5. Git资料

    git作为流行的分布式版本管理系统,虽然入门有点难,不过学会还是很有用的,尤其是针对技术人员.它从2005年Linux作者两周用C++写的一个版本发展到现在这么流行也是有原因的. Downloads  ...

  6. docker基于commit命令创建支持ssh服务的镜像

    以centos为基础,目的使用ssh服务远程连接docker容器. 环境:宿主机centos7(宿主机ip地址为192.168.164.130),直接搜索docker的centos镜像,下载最新版本. ...

  7. C语言:宽字符集操作函数(unicode编码)

    C语言:宽字符集操作函数(unicode编码) 字符分类: 宽字符函数 普通C函数描述 iswalnum() isalnum() 测试字符是否为数字或字母 iswalpha() isalpha() 测 ...

  8. java websocket @ServerEndpoint注解说明

    http://www.blogjava.net/qbna350816/archive/2016/07/24/431302.html https://segmentfault.com/q/1010000 ...

  9. Bootstrap-Other:v2 教程

    ylbtech-Bootstrap-Other:v2 教程 1.返回顶部 1. Bootstrap v2 教程 Bootstrap,来自 Twitter,是基于 HTML.CSS.JAVASCRIPT ...

  10. 在Visual Studio调试器中显示Unreal的数据类型的值

    转自:https://blog.csdn.net/witton/article/details/5977766 在Unreal引擎中大量使用了自定义的数据类型如:FName,FString,TArra ...