Monday, December 26, 2011

Speed up SSH and FTP logins

Scenario: You're working in the office, and a foot of snow comes down out side, killing your Internet connection, all of a sudden, your FTP server on the local network starts timing out, and SSHing in to the server is unbearably slow to get to the password prompt.

What happened is that FTP and SSH services do a reverse DNS query to ensure that hosts actually are who they say they are, when your connection went out, they were no longer able to do this, but keep trying anyway, slowing things down to the point of frustration or timeout.

The fix is simple, but makes your connections a little less secure, as this check won't be performed on all connections, not a big deal if your boxes only face internal networks.

First, (assuming you're using openssh) fix SSH:

echo "UseDNS no" >> /etc/ssh/sshd_config

Next (assuming your're using pure-ftpd) fix FTP:

echo 'yes' > /etc/pure-ftpd/conf/DontResolve

Restart both services through /etc/init.d or upstart and you're set!

No comments:

Post a Comment