Operations guide

How to speed up slow SSH login on CentOS 7 before deeper troubleshooting

A practical guide to using optimize_centos7_ssh.sh when an old CentOS 7 host pauses too long before the SSH password prompt because of reverse DNS, GSSAPI, or IPv6 fallback.

6 min read · 2026-04-07

When this script is the right first move

This script is meant for hosts where SSH itself works, but the login path is slow before the password prompt or before the shell becomes interactive.

That pattern usually points to daemon-side waits such as reverse DNS lookup, GSSAPI negotiation, or an IPv6 path that exists just enough to delay but not enough to work well.

What the script changes and why it works

The script writes three common first-pass settings into sshd_config: UseDNS no, GSSAPIAuthentication no, and AddressFamily inet.

The first removes reverse lookup waits, the second avoids unused Kerberos-style negotiation on hosts that do not use it, and the third stops legacy CentOS 7 hosts from wasting time on bad IPv6 paths.

Terminal output showing optimize_centos7_ssh.sh backing up sshd_config, validating with sshd -t, and restarting sshd successfully
A healthy run should show a config backup, the three SSH tuning changes, a successful sshd -t validation, and only then the sshd restart.
  • Back up /etc/ssh/sshd_config first
  • Write the settings idempotently instead of appending duplicates
  • Run sshd -t before restart
  • Restart sshd only after validation passes

Recommended operating pattern on production-like hosts

Keep one SSH session open, run the helper script from a second session, and only close the original connection after you verify that a fresh login is fast and stable.

If the host depends on Kerberos or real IPv6-only reachability, do not apply these defaults blindly. This script is meant to remove common stalls, not to replace a real SSH policy review.

Related topics

CentOS 7 maintenance and recovery

Keep legacy CentOS 7 hosts installable and maintainable when yum repositories fail, mirrors expire, or Docker data needs to be moved off a crowded disk.

Open topic

Problem pages

Why is CentOS 7 SSH login so slow

The usual causes are reverse DNS lookup, GSSAPI auth negotiation, and sometimes IPv6 fallback. Disable those waits before doing deeper SSH troubleshooting.

Open page