By default, ssh server performs a reverse DNS lookup for authentication requests. This can be so annoying as you wait ten’s of seconds for the lookup to finish. You may experience a delay before receiving a password prompt while accessing a remote system via ssh.
This guide will show you how to disable SSH reverse DNS lookups in a Linux/Unix system. The method discussed here works for all Linux and Unix based operating systems running OpenSSH Server.
To disable reverse DNS lookup, open OpenSSH server configuration file:
sudo nano /etc/ssh/sshd_config
And setting the line:
UseDNS no
This directive tells sshd service to ignore checks for resolved hostname IP address if it maps back to the same ip address or not. Please note that this does not prevent sshd server from performing any DNS lookups.
Restart sshd service after making the change:
# Systemd
sudo systemctl restart sshd
# SysVinit/Upstart
sudo service sshd restart
If you still experience delay in SSH, consider disabling GSSAPIAuthentication if is active.
GSSAPIAuthentication no
Then restart sshd service.
# Systemd
sudo systemctl restart sshd
# SysVinit/Upstart
sudo service sshd restart
More articles:
Set Up Two factor (2FA) Authentication for SSH on CentOS / RHEL
Easy way to Create SSH tunnels on Linux CLI
Change or update SSH key Passphrase on Linux / Unix
Installing sshfs and using sshfs on Ubuntu / Fedora / Arch / CentOS