centOS ssh login slow solution

centOS ssh login is slow

There is an executive machine that uses ssh to log in very slowly. After entering the password, it takes 2 to 30 seconds to log in. It is unbearable. Check the log and find that it is stuck in Entering interactive session

Online solution:

  1. Modify the machine's /etc/ssh/sshd_config

添加  UseDNS no
  1. Modify /etc/ssh/ssh_config of the target machine

添加 GSSAPIAuthentication no

doesn't work

Use ssh -v [email protected] to find out


ssh -v 80@30.35.108.5

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/liudan/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/liudan/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 192.168.1.1:22 as '80'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:fchZB16JdbpNZqqZcFxufdzPsRX3Om8Qm4Tgn1TqLfg
debug1: Host '192.168.1.1' is known and matches the ECDSA host key.
debug1: Found key in /Users/liudan/.ssh/known_hosts:27
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/liudan/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /Users/liudan/.ssh/id_dsa
debug1: Trying private key: /Users/liudan/.ssh/id_ecdsa
debug1: Trying private key: /Users/liudan/.ssh/id_ed25519
debug1: Next authentication method: password
80@192.168.1.1's password: 
debug1: Authentication succeeded (password).
Authenticated to 192.168.1.1 ([192.168.1.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.

卡住了20秒+

Solution

reason

The systemd-logind service is not restarted. You can view the status with systemctl status systemd-logind

The solution is to restart the service

systemctl restart systemd-logind

Re-ssh is quick

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326516835&siteId=291194637