How to disable SSH reverse DNS lookup in Linux/Unix systems

By default, the ssh server performs reverse DNS lookups for authentication requests. This can be very annoying when you wait for tens of seconds to complete the search. When accessing a remote system via ssh, you may experience a delay before receiving the password prompt.

This guide will show you how to disable SSH reverse DNS lookup on Linux/Unix systems. The methods discussed here are applicable to all Linux and Unix-based operating systems running OpenSSH servers.

To disable reverse DNS lookup, open the OpenSSH server configuration file:

sudo nano /etc/ssh/sshd_config

And set the line:

UseDNS no

This directive tells the sshd service to ignore the check of the resolved hostname IP address, regardless of whether it maps back to the same IP address. Note that this will not prevent the sshd server from performing any DNS lookups.

Restart the sshd service after the change:

# Systemd
$ sudo systemctl restart sshd

# SysVinit/Upstart
$ sudo service sshd restart

If you still experience delays in SSH, consider disabling GSSAPIAuthentication if it is active.

GSSAPIAuthentication no

Then restart the sshd service.

# Systemd
$ sudo systemctl restart sshd

# SysVinit/Upstart
$ sudo service sshd restart

More articles:

How to set up two-factor (2FA) authentication for SSH on CentOS / RHEL

The easy way to create an SSH tunnel on the Linux CLI

How to change or update SSH key password on Linux / Unix

Install sshfs and use sshfs on Ubuntu / Fedora /Arch/CentOS