Solution to slow centos SSH remote connection

Source: Internet
Author: User
Tags ssh server

Solution to slow centos SSH remote connection

The primary cause of slow connection is DNS resolution.

Solution:

1. Change the configuration in the/etc/ssh/sshd_config file on the ssh server as follows:
UseDNS no
# GSSAPI options
GSSAPIAuthentication no
Then, run the/etc/init. d/sshd restart command to restart the sshd process to make the above configuration take effect. The connection is generally not slow.

If it is still slow, check whether the host name corresponding to 127.0.0.1 and
The uname-n results are the same, or you can add the local ip address and hostname (uname-n results) to/etc/hosts.

[Python] view plaincopy
  1. [Root @ C64 ~] # Uname-n
  2. C64
  3. [Root @ C64 ~] # Cat/etc/hosts
  4. # Modibyoldboy11: 122013/9/24
  5. 127.0.0.1C64localhostlocalhost.localdomainlocalhost4localhost4.localdomain4
  6. : 1localhostlocalhost. localdomainlocalhost6localhost6. localdomain6
  7. 10.0.0.18C64
  8. ################


Use the ssh-v debugging function to find the cause of slowness
In fact, you can use the following command to debug the slow details (learning this idea is very important ).

[Python] view plaincopy
  1. [Root @ C64 ~] # Ssh-vroot @ IP Address
  2. OpenSSH_5.3p1, OpenSSL1.0.0-fips29Mar2010
  3. Debug1: Readingconfigurationdata/etc/ssh/ssh_config
  4. Debug1: Applyingoptionsfor *
  5. Debug1: Connectingto10.0.0.19 [10.0.0.19] port22.
  6. Debug1: Connectionestablished.
  7. Debug1: permanently_set_uid: 0/0
  8. Debug1: identityfile/root/. ssh/identitytype-1
  9. Debug1: identityfile/root/. ssh/id_rsatype-1
  10. Debug1: identityfile/root/. ssh/id_dsatype-1
  11. Debug1: Remoteprotocolversion2.0, remotesoftwareversionOpenSSH_4.3
  12. Debug1: match: OpenSSH_4.3patOpenSSH_4 *
  13. Debug1: Enablingcompatibilitymodeforprotocol2.0
  14. Debug1: LocalversionstringSSH-2.0-OpenSSH_5.3
  15. Debug1: SSH2_MSG_KEXINITsent
  16. Debug1: SSH2_MSG_KEXINITreceived
  17. Debug1: kex: server-> clientaes128-ctrhmac-md5none
  18. Debug1: kex: client-> serveraes128-ctrhmac-md5none
  19. Debug1: SSH2_MSG_KEX_DH_GEX_REQUEST (1024 <1024) sent
  20. Debug1: expectingSSH2_MSG_KEX_DH_GEX_GROUP
  21. Debug1: SSH2_MSG_KEX_DH_GEX_INITsent
  22. Debug1: expectingSSH2_MSG_KEX_DH_GEX_REPLY
  23. Theauthenticityofhost '10. 0.0.19 (10.0.0.19) 'can' tbeestablished.
  24. RSAkeyfingerprintisca: 18: 42: 76: 0e: 5a: 1c: 7d: ef: fc: 24: 75: 80: 11: ad: f9.
  25. Areyousureyouwanttocontinueconnecting (yes/no )? Yes
  26. ======> Here is the interaction prompt for saving the key.
  27. Warning: Permanentlyadded '10. 0.0.19 '(RSA) tothelistofknownhosts.
  28. Debug1: ssh_rsa_verify: signaturecorrect
  29. Debug1: SSH2_MSG_NEWKEYSsent
  30. Debug1: expectingSSH2_MSG_NEWKEYS
  31. Debug1: SSH2_MSG_NEWKEYSreceived
  32. Debug1: SSH2_MSG_SERVICE_REQUESTsent
  33. Debug1: SSH2_MSG_SERVICE_ACCEPTreceived
  34. Debug1: Authenticationsthatcancontinue: publickey, password
  35. Debug1: Nextauthenticationmethod: publickey
  36. Debug1: Tryingprivatekey:/root/. ssh/identity
  37. Debug1: Tryingprivatekey:/root/. ssh/id_rsa
  38. Debug1: Tryingprivatekey:/root/. ssh/id_dsa
  39. Debug1: Nextauthenticationmethod: password
  40. Root@10.0.0.19 'spassword:
  41. <Strong >=====> here is the interaction prompt prompting you to enter the password. </Strong>
  42. Debug1: Authenticationsucceeded (password ).
  43. Debug1: channel0: new [client-session]
  44. Debug1: Enteringinteractivesession.
  45. Debug1: Sendingenvironment.
  46. Debug1: SendingenvLANG = en_US.UTF-8
  47. Lastlogin: TueSep2410: 30: 022013from10. 0.0.18
  48. <Strong> If the remote connection is slow, you can determine where the connection is located. </Strong>
  49. [Root @ C64_A ~] # Ssh-voldboy @ IP Address
  50. OpenSSH_5.3p1, OpenSSL1.0.0-fips29Mar2010
  51. Debug1: Readingconfigurationdata/etc/ssh/ssh_config
  52. Debug1: Applyingoptionsfor *
  53. Debug1: Connectingto10.0.0.17 [10.0.0.17] port22.
  54. Debug1: Connectionestablished.
  55. Debug1: permanently_set_uid: 0/0
  56. Debug1: identityfile/root/. ssh/identitytype-1
  57. Debug1: identityfile/root/. ssh/id_rsatype-1
  58. Debug1: identityfile/root/. ssh/id_dsatype2
  59. Debug1: Remoteprotocolversion2.0, remotesoftwareversionOpenSSH_5.3
  60. Debug1: match: OpenSSH_5.3patOpenSSH *
  61. Debug1: Enablingcompatibilitymodeforprotocol2.0
  62. Debug1: LocalversionstringSSH-2.0-OpenSSH_5.3
  63. Debug1: SSH2_MSG_KEXINITsent
  64. Debug1: SSH2_MSG_KEXINITreceived
  65. Debug1: kex: server-> clientaes128-ctrhmac-md5none
  66. Debug1: kex: client-> serveraes128-ctrhmac-md5none
  67. Debug1: SSH2_MSG_KEX_DH_GEX_REQUEST (1024 <1024) sent
  68. Debug1: expectingSSH2_MSG_KEX_DH_GEX_GROUP
  69. Debug1: SSH2_MSG_KEX_DH_GEX_INITsent
  70. Debug1: expectingSSH2_MSG_KEX_DH_GEX_REPLY
  71. Debug1: Host '10. 0.0.17 'isknownandmatchestheRSAhostkey.
  72. Debug1: Foundkeyin/root/. ssh/known_hosts: 2
  73. Debug1: ssh_rsa_verify: signaturecorrect
  74. Debug1: SSH2_MSG_NEWKEYSsent
  75. Debug1: expectingSSH2_MSG_NEWKEYS
  76. Debug1: SSH2_MSG_NEWKEYSreceived
  77. Debug1: SSH2_MSG_SERVICE_REQUESTsent
  78. Debug1: SSH2_MSG_SERVICE_ACCEPTreceived
  79. Debug1: Authenticationsthatcancontinue: publickey, gssapi-keyex, gssapi-with-mic, password
  80. Debug1: Nextauthenticationmethod: gssapi-keyex
  81. Debug1: NovalidKeyexchangecontext
  82. Debug1: Nextauthenticationmethod: gssapi-with-mic
If the above configuration is not configured, It is found to be stuck in gssapi. It is probably a problem with gssapi.

In fact, the SSH service should be optimized in the linux system optimization section.

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.