SSH Login Takes a Long Time
Has it ever happened to you that logging in to an SSH server takes a long time? More than, say 20, 30 seconds? Well, there are many solutions out there to fix it, some may even make your system less secure. So let’s go to the source of SSH, so to speak, for a resolution. If you head over to ssh(1) takes a long time to connect or log in, you will see that it’s an issue with DNS resolution. To resolve this issue, try the following steps:
You need to change the sshd config file …
sudo vim /etc/ssh/sshd_config
… and make sure you have this line uncommented
UseDNS no
Save the file and restart SSH daemon (service) like so
sudo service sshd restart (Fedora, Red Hat, CentOS)
or
sudo /etc/init.d/sshd restart (Debian, Ubuntu)
Hat tip: Slow SSH login;
Quick Introduction to Advanced SSH
I will not go through the complete overview of advanced SSH. For that, you may either use a search engine or read the following articles: SSH Advanced Techniques; Advanced SSH Usage; SSH Host Key Protection; ssh-keygen Tutorial; and SSH authorized_keys howto. What I will provide, though, are three quick commands:
Generate new public/private key pair, using RSA as encryption type and key strength as 4096 bits:
ssh-keygen -t rsa -b 4096
Change the passphrase used in the key
ssh-keygen -f id_rsa -p
Check the fingerprint of a public key
ssh-keygen -f id_rsa.pub -l