Hostxpeed
Login Get Started →
Troubleshooting

Fix SSH Slow Login

4 min read
30 views
Jun 12, 2026

Identifying Slow Login Issues

Slow login (5-30 seconds) is usually caused by:

  • DNS reverse lookups
  • GSSAPI authentication attempts
  • Large ~/.ssh/authorized_keys file
  • PAM module delays
  • Resource constraints

Fix 1: Disable DNS Lookups

Edit /etc/ssh/sshd_config:

UseDNS no

Then restart SSH:

sudo systemctl restart sshd

This is the most common fix, reducing login time from 10+ seconds to instant.

Fix 2: Disable GSSAPI Authentication

Add to /etc/ssh/sshd_config:

GSSAPIAuthentication no

Also on client side (~/.ssh/config or /etc/ssh/ssh_config):

GSSAPIAuthentication no

Fix 3: Check .bashrc or .profile Delays

Your shell startup files might have slow commands:

# Add debugging to ~/.bashrc
set -x
# At the end of ~/.bashrc
set +x

Then login and watch for delays. Common culprits:

  • Network commands (curl, wget)
  • Large directory traversals
  • Version control status checks

Fix 4: Reduce Authorized Keys Size

If you have many SSH keys in authorized_keys, consider removing unused ones or using Match Blocks in sshd_config.

Fix 5: Check PAM Modules

Comment out unnecessary PAM modules in /etc/pam.d/sshd:

# Example - disable unused modules
# auth optional pam_motd.so
# session optional pam_mail.so

Fix 6: Use ControlMaster for Multiple Sessions

Client-side ~/.ssh/config:

Host *
    ControlMaster auto
    ControlPath ~/.ssh/controlmasters/%r@%h:%p
    ControlPersist 10m
mkdir -p ~/.ssh/controlmasters

This reuses existing connections, eliminating login delays for subsequent sessions.

Was this article helpful?