I’ve had this issue a couple of times, when I attempt to ssh from our CentOS jump server to another CentOS server, I have had ssh hang and take up to 60 seconds or more before I get a bash prompt on the remote server.
I have found this is usually caused by a couple of symptoms.
This can be caused by incorrectly configured DNS on the server which your connecting. This can happened when tcp wrappers or sshd attempt to perform a reverse lookup on your connecting IP address it must wait for DNS to timeout. If this is your problem it can be resolved by update your resolve.conf
Update your name servers, in this example we use Google’s DNS servers:
nameserver 220.127.116.11 nameserver 18.104.22.168
That should speed it up.
In some situations DNS isn’t the issue. So, if didn’t resolve your issue with slow connections. Sometimes you need to make an adjustment to your sshd configuration file, and change the GSSAPIAuthentication setting
Change this entry from
to no, to disable
then restart sshd
systemctl restart sshd
After making these changes attempt to ssh back into the server to verify you’re connecting quickly.
I always recommend doing my ssh connecting in a new window. Just in the off chance you miss typed something in the sshd configuration that will keep an open window to server so if you get a connection refused. You can make any corrections to your sshd configuration.
This has resolved the issue for me, and should help you as well.