How to fix a slow ssh login issue on Linux


If you have to wait very long for SSH password prompt, there could be several things that may go wrong. To troubleshoot the root cause of slow SSH login, you can run ssh command with "-vvv" option, which will show you what's happening behind the scene during SSH login.

Here are possible solutions to the delayed SSH login problem.

Disable GSSAPI Authentication

One possible culprit (as indicated in the SSH client log above) is GSSAPI authentication. During SSH login, SSH client goes through a series of authentication steps, and one of them is GSSAPI authentication, where an SSH server contacts a GSSAPI server to validate client authentication. On Linux distros such as CentOS, GSSAPI authentication is enabled by default, and GSS failure can add long delay in SSH session start.

$sudo vi /etc/ssh/sshd_config 
change yes to no

GSSAPIAuthentication no
 

Disable Reverse DNS Lookup

$sudo vi /etc/ssh/sshd_config
 
Uncommand this: 
UseDNS no 

Then restart SSH server:
$ sudo /etc/init.d/ssh restart  (Debian, Ubuntu or Linux Mint)
$ sudo systemctl restart sshd (Fedora)
$ sudo service sshd restart (CentOS or RHEL)
 
===========================
http://ask.xmodulo.com/fix-slow-ssh-login-issue-linux.html