Fix Slow SSH/SFTP Logins on Ubuntu
-
This may seem super trivial for some of your Linux veterans, but I am working through a couple of projects that are broadening my Linux skill set. I ran into an issue where I would try to connect via SSH to an Ubuntu server, running OpenSSH and when logging in, it would take about 10 seconds to prompt for the password and about 30 seconds to complete the login after authenticating me. This also affected trying to use SFTP via filezilla to grab a file from the server.
After some Googling and trial and error, I found that what fixed my problem was to add a line to the sshd_config file that apparently disables the default behavior of trying to use reverse IP resolution.
The steps I took:
-
sudo nano /etc/ssh/ssh_config
-
Add this line to the end of the file:
UseDNS no -
Ctrl X to exit.
-
Y to save.
-
"Enter" to overwrite the existing file.
-
I restarted the SSH service but I don't know if it was necessary.
sudo service ssh restart
-
-
Yeah, DNS lookups are a killer for SSH. Almost nothing that people use as an end point has a PTR record and so it always waits for a time out.
-
@wrx7m said:
- I restarted the SSH service but I don't know if it was necessary.
sudo service ssh restart
It is.
- I restarted the SSH service but I don't know if it was necessary.