centOS ssh登录缓慢解决

来源:互联网 发布:呼叫中心的网络构架 编辑:程序博客网 时间:2024/05/15 13:18

centOS ssh登录缓慢

有一台执行机使用ssh登录很慢,输入完密码后需要等待2,30秒才能够登录进去,简直不能忍.查看日志发现卡在Entering interactive session

网上解决办法:

  1. 修改本机的 /etc/ssh/sshd_config
添加  UseDNS no
  1. 修改目标机器的 /etc/ssh/ssh_config
添加 GSSAPIAuthentication no

并没有什么作用

使用ssh -v user@192.168.1.1排查发现

ssh -v 80@30.35.108.5OpenSSH_6.9p1, LibreSSL 2.1.8debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /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 1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_rsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_dsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_dsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_ecdsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_ecdsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_ed25519 type -1debug1: key_load_public: No such file or directorydebug1: identity file /Users/liudan/.ssh/id_ed25519-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.9debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000debug1: Authenticating to 192.168.1.1:22 as '80'debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: server->client chacha20-poly1305@openssh.com <implicit> nonedebug1: kex: client->server chacha20-poly1305@openssh.com <implicit> nonedebug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug1: Server host key: ecdsa-sha2-nistp256 SHA256:fchZB16JdbpNZqqZcFxufdzPsRX3Om8Qm4Tgn1TqLfgdebug1: Host '192.168.1.1' is known and matches the ECDSA host key.debug1: Found key in /Users/liudan/.ssh/known_hosts:27debug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: SSH2_MSG_SERVICE_REQUEST sentdebug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,passworddebug1: Next authentication method: publickeydebug1: Offering RSA public key: /Users/liudan/.ssh/id_rsadebug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,passworddebug1: Trying private key: /Users/liudan/.ssh/id_dsadebug1: Trying private key: /Users/liudan/.ssh/id_ecdsadebug1: Trying private key: /Users/liudan/.ssh/id_ed25519debug1: Next authentication method: password80@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.comdebug1: Entering interactive session.卡住了20秒+

解决办法

原因

systemd-logind服务没有重启导致,可以systemctl status systemd-logind查看状态

解决方法就是重启该服务

systemctl restart systemd-logind

重新ssh就很快了

原创粉丝点击