"Go" SSH login very slow workaround

Source: Internet
Author: User
Tags hmac reverse dns

Using an SSH client (such as: Putty) to connect to a Linux server may wait 10-30 seconds before prompting for a password. Serious impact on productivity. Login is slow, log on up after normal speed, there are two main possible reasons for this situation:

1. DNS Reverse resolution problem

OPENSSH will authenticate the IP when the user logs in, it locates the hostname according to the user's IP using reverse DNS, then uses DNS to find the IP address, and finally matches the login IP is legitimate. If the client's IP does not have a domain name, or if the DNS server is slow or not, logging in will take time.

Workaround: Modify the SSHD server-side configuration on the target server and restart the sshd

    1. Vi/etc/ssh/sshd_config
    2. Usedns No
2. Turn off GSSAPI authentication for SSH

with ssh-v [email protected] You can see the following information when you log in:

    1. Debug1:next Authentication Method:gssapi-with-mic
    2. Debug1:unspecified GSS failure. Minor code may provide more information

Note:ssh-vvv [email protected] can see more detailed debug information

Workaround:

Modifying the SSHD server-side configuration

    1. Vi/etc/ssh/ssh_config
    2. Gssapiauthentication No

You can log in using ssh-o gssapiauthentication=no [email protected]

GSSAPI (Generic Security Services application Programming Interface) is a common network security system interface similar to Kerberos 5. This interface is a package of different client server security mechanisms to eliminate the different security interfaces and reduce programming difficulty. However, this interface will be problematic if the target machine has no domain name resolution.

Using Strace to see, SSH after the verification of the key, the authentication gssapi-with-mic, the first to connect to the DNS server, after which there will be other operations

  1. [[Email protected] ~] # SSH-VVV [email protected]
  2. OPENSSH_5.3P1, OpenSSL 1.0.1e-fips 2013
  3. Debug1:reading Configuration Data/etc/ssh/ssh_config
  4. debug1:applying options for *
  5. Debug2:ssh_connect:needpriv 0
  6. Debug1:connecting to 192.168.3.44 [192.168.3.44] Port 22.
  7. Debug1:connection established.
  8. debug1:permanently_set_uid:0/0
  9. Debug1:identity file/root/.ssh/identity type-1
  10. Debug1:identity file/root/.ssh/identity-cert type-1
  11. Debug1:identity file/root/.ssh/id_rsa type-1
  12. Debug1:identity file/root/.ssh/id_rsa-cert type-1
  13. Debug1:identity file/root/.ssh/id_dsa type-1
  14. Debug1:identity file/root/.ssh/id_dsa-cert type-1
  15. Debug1:identity file/root/.ssh/id_ecdsa type-1
  16. Debug1:identity file/root/.ssh/id_ecdsa-cert type-1
  17. Debug1:remote Protocol version 2.0, Remote software version openssh_5.3
  18. debug1:match:openssh_5.3 Pat Openssh*
  19. debug1:enabling compatibility mode for Protocol 2.0
  20. Debug1:local version string ssh-2.0-openssh_5.3
  21. DEBUG2:FD 3 Setting O_nonblock
  22. Debug1:ssh2_msg_kexinit sent
  23. Debug3:wrote 960 bytes For a total of 981
  24. Debug1:ssh2_msg_kexinit received
  25. DEBUG2:KEX_PARSE_KEXINIT:DIFFIE-HELLMAN-GROUP-EXCHANGE-SHA256,DIFFIE-HELLMAN-GROUP-EXCHANGE-SHA1, Diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
  26. Debug2:kex_parse_kexinit: [Email protected],[email protected],[email protected],[email PROTECTED],SSH-RSA,SSH-DSS
  27. DEBUG2:KEX_PARSE_KEXINIT:AES128-CTR,AES192-CTR,AES256-CTR,ARCFOUR256,ARCFOUR128,AES128-CBC,3DES-CBC, Blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
  28. DEBUG2:KEX_PARSE_KEXINIT:AES128-CTR,AES192-CTR,AES256-CTR,ARCFOUR256,ARCFOUR128,AES128-CBC,3DES-CBC, Blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
  29. debug2:kex_parse_kexinit:hmac-Md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[ Email protected],hmac-sha1-96,hmac-md5-96
  30. debug2:kex_parse_kexinit:hmac-Md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[ Email protected],hmac-sha1-96,hmac-md5-96
  31. Debug2:kex_parse_kexinit:none,[email protected],zlib
  32. Debug2:kex_parse_kexinit:none,[email protected],zlib
  33. Debug2:kex_parse_kexinit:
  34. Debug2:kex_parse_kexinit:
  35. Debug2:kex_parse_kexinit:first_kex_follows 0
  36. Debug2:kex_parse_kexinit:reserved 0
  37. DEBUG2:KEX_PARSE_KEXINIT:DIFFIE-HELLMAN-GROUP-EXCHANGE-SHA256,DIFFIE-HELLMAN-GROUP-EXCHANGE-SHA1, Diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
  38. Debug2:kex_parse_kexinit:ssh-rsa,ssh-dss
  39. DEBUG2:KEX_PARSE_KEXINIT:AES128-CTR,AES192-CTR,AES256-CTR,ARCFOUR256,ARCFOUR128,AES128-CBC,3DES-CBC, Blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
  40. DEBUG2:KEX_PARSE_KEXINIT:AES128-CTR,AES192-CTR,AES256-CTR,ARCFOUR256,ARCFOUR128,AES128-CBC,3DES-CBC, Blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
  41. debug2:kex_parse_kexinit:hmac-Md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[ Email protected],hmac-sha1-96,hmac-md5-96
  42. debug2:kex_parse_kexinit:hmac-Md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[ Email protected],hmac-sha1-96,hmac-md5-96
  43. Debug2:kex_parse_kexinit:none,[email protected]
  44. Debug2:kex_parse_kexinit:none,[email protected]
  45. Debug2:kex_parse_kexinit:
  46. Debug2:kex_parse_kexinit:
  47. Debug2:kex_parse_kexinit:first_kex_follows 0
  48. Debug2:kex_parse_kexinit:reserved 0
  49. Debug2:mac_setup:found hmac-MD5
  50. Debug1:kex:server->client aes128-ctr hmac-MD5 None
  51. Debug2:mac_setup:found hmac-MD5
  52. Debug1:kex:client->server aes128-ctr hmac-MD5 None
  53. Debug1:ssh2_msg_kex_dh_gex_request (1024<1024<8192) sent
  54. Debug1:expecting Ssh2_msg_kex_dh_gex_group
  55. Debug3:wrote bytes for a total of 1005
  56. Debug2:dh_gen_key:priv Key Bits set:120/256
  57. Debug2:bits set:506/1024
  58. Debug1:ssh2_msg_kex_dh_gex_init sent
  59. Debug1:expecting ssh2_msg_kex_dh_gex_reply
  60. Debug3:wrote 144 bytes For a total of 1149
  61. Debug3:check_host_in_hostfile:host 192.168.3.44 filename/root/.ssh/known_hosts
  62. Debug3:check_host_in_hostfile:host 192.168.3.44 filename/root/.ssh/known_hosts
  63. Debug3:check_host_in_hostfile:match Line 8
  64. Debug1:host ' 192.168.3.44 ' is known and matches the RSA Host key.
  65. Debug1:found Key In/root/.ssh/known_hosts:8
  66. Debug2:bits set:527/1024
  67. Debug1:ssh_rsa_verify:signature correct
  68. Debug2:kex_derive_keys
  69. Debug2:set_newkeys: Mode 1
  70. Debug1:ssh2_msg_newkeys sent
  71. Debug1:expecting Ssh2_msg_newkeys
  72. Debug3:wrote bytes for a total of 1165
  73. Debug2:set_newkeys: mode 0
  74. Debug1:ssh2_msg_newkeys received
  75. Debug1:ssh2_msg_service_request sent
  76. Debug3:wrote bytes for a total of 1213
  77. Debug2:service_accept:ssh-userauth
  78. Debug1:ssh2_msg_service_accept received
  79. Debug2:key:/root/.ssh/identity ((nil))
  80. Debug2:key:/root/.ssh/id_rsa ((nil))
  81. Debug2:key:/root/.ssh/id_dsa ((nil))
  82. Debug2:key:/root/.ssh/id_ecdsa ((nil))
  83. Debug3:wrote bytes for a total of 1277
  84. Debug1:authentications that can Continue:publickey,gssapi-keyex,gssapi-with-mic,password
  85. Debug3:start over, passed a different list Publickey,gssapi-keyex,gssapi-with-mic,password
  86. Debug3:preferred Gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
  87. Debug3:authmethod_lookup Gssapi-keyex
  88. Debug3:remaining Preferred:gssapi-with-mic,publickey,keyboard-interactive,password
  89. Debug3:authmethod_is_enabled Gssapi-keyex
  90. Debug1:next Authentication Method:gssapi-keyex
  91. Debug1:no Valid Key Exchange context
  92. Debug2:we did not send a packet, disable method
  93. Debug3:authmethod_lookup gssapi-with-mic
  94. Debug3:remaining Preferred:publickey,keyboard-interactive,password
  95. Debug3:authmethod_is_enabled gssapi-with-mic
  96. Debug1:next Authentication Method:gssapi-with-mic
  97. Debug3:trying to reverse map address 192.168.3.44.
  98. Debug1:unspecified GSS failure. Minor code may provide more information
  99. Cannot determine realm for numeric host address
  100. Debug1:unspecified GSS failure. Minor code may provide more information
  101. Cannot determine realm for numeric host address
  102. Debug1:unspecified GSS failure. Minor code may provide more information
  103. Debug1:unspecified GSS failure. Minor code may provide more information
  104. Cannot determine realm for numeric host address
  105. Debug2:we did not send a packet, disable method
  106. Debug3:authmethod_lookup PublicKey
  107. Debug3:remaining Preferred:keyboard-interactive,password
  108. Debug3:authmethod_is_enabled PublicKey
  109. Debug1:next Authentication Method:publickey
  110. Debug1:trying private key:/root/.ssh/identity
  111. Debug3:no such identity:/root/.ssh/identity
  112. Debug1:trying private key:/root/.ssh/id_rsa
  113. Debug3:no such identity:/root/.ssh/id_rsa
  114. Debug1:trying private key:/ROOT/.SSH/ID_DSA
  115. Debug3:no such identity:/ROOT/.SSH/ID_DSA
  116. Debug1:trying private key:/ROOT/.SSH/ID_ECDSA
  117. Debug3:no such identity:/ROOT/.SSH/ID_ECDSA
  118. Debug2:we did not send a packet, disable method
  119. Debug3:authmethod_lookup Password
  120. Debug3:remaining preferred:, password
  121. debug3:authmethod_is_enabled Password
  122. Debug1:next Authentication Method:password
  123. [email protected] ' s password:

This article was reproduced in: https://blog.linuxeye.com/420.html

"Go" SSH login very slow workaround

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.