AzoftSpotlightHow to speed up the login via SSH in Ubuntu by 100 times

How to speed up the login via SSH in Ubuntu by 100 times

By Svarychevski Michail on April 18, 2011

For a long time I had a trouble with slow remote login to all my Ubuntu servers (all 2). Slow login means 2-3 seconds in my case. It is not so dramatic of course but when the login is via key you want that everything works like a flash -  ultimately we have not the 486SX.
Long googleing suggested only standard solutions like:

  1. UseDNS no in /etc/ssh/sshd_config — speeds up login in case of slow DNS. I have a local cash DNS, thus everything was fast without it.
  2. Forced IPv4 in the SSH client didn't help — probably not everybody has such problem with speed.

And my question with bounty at askubuntu.com was despondently hanging there for weeks without any answer…

It appeared, the /etc/motd file in Ubuntu which was used by our grandparents for really important tasks, should be used quite "creatively" – motd was generated to the 10th version at the crontab task, that fulfilled tons of tasks, among them checking for updates on the canonical server (and much more). Switch off via the 'update-motd –disable'.

It isn't so easy in the 10th version, because the motd generation was carried to the PAM modules, which are fulfilled straight in the moment of login and eat up those precious 2-3 seconds of time, while user is impatiently looking in the black Terminal window. What to do:

  1. In the files /etc/pam.d/login and /etc/pam.d/sshd cut out the string «session optional pam_motd.so»
  2. Pull down the paid monitoring components set by default:
    aptitude remove landscape-client landscape-common

After that you can finally edit the /etc/motd as you like it.

In the /etc/ssh/sshd_config look whether there is the 'PrintMotd yes', if you still need it.

Ready! Login to server is now immediate :-)

PS. If you login with a key, at the same length RSA key is checked faster than DSA (approximately by 4 times) — you can see the differ even on the modern hardware in the keys from 2048.


To learn more about Svarychevski Michail and his latest projects you can visit his personal site at at http://3.14.by/en/


 

Enhanced by Zemanta