Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: OpenSSH Slow: Hanging at SSH2_MSG_SERVICE_ACCEPT received  (Read 7239 times)

0 Members and 1 Guest are viewing this topic.

vyshakhv

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
OpenSSH Slow: Hanging at SSH2_MSG_SERVICE_ACCEPT received
« on: August 12, 2017, 03:08:50 pm »
When you are trying to ssh to a remote server, after you enter the username, it takes a lot of time before it displays the password prompt. Basically, the SSH ( openSSH ) is slow during authentication process.debug1: SSH2_MSG_NEWKEYS sent

If your ssh login from localhost to remotehost is slow, enable the ssh debugging while starting the ssh connection using option -v as shown below.

After it displays the “debug1: SSH2_MSG_SERVICE_ACCEPT received” message, ssh session will be hanging for almost a minute before it continues to the next debug statement.
Code: [Select]
ssh root@168.133.5.34 -v
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received <-- OpenSSH hanging here for 1 min

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password

Solution: set UseDNS to no in sshd_config file

To fix this performance issue while connecting to a remote server using ssh, set the UseDNS to no as shown below in your /etc/ssh/sshd_config file.
Code: [Select]
$ vi /etc/ssh/sshd_config
UseDNS no

Restart the openssh and connect to the remote server again, which should be quick this time and will not hang at SSH2_MSG_SERVICE_ACCEPTED.
Code: [Select]
# service sshd restart