Setting up an autologin account to a SSH server could prove a pretty useful thing to do, especially if you work on remote servers quite often. This means that login through SSH won’t prompt you for a password everytime you authenticate, but at the same time, keeps the high security standard of SSH.

Setting the SSH autologin is a pretty simple thing to do, just open a terminal on the computer you are connecting FROM and follow these steps:

Generate a RSA 2048bit public/private key pair (press enter to all prompts):

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/rev/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rev/.ssh/id_rsa.
Your public key has been saved in /home/rev/.ssh/id_rsa.pub.
The key fingerprint is:
14:99:74:1a:cb:33:c5:8f:75:8a:87:5e:f1:00:d7:e0 rev@linuxlove
The key's randomart image is:
+--[ RSA 2048]----+
| .+++.oo |
| .oB.o+ o |
| B *E* |
| . o+ = . |
| S. o |
| . |
| |
| |
| |
+-----------------+

Copy the public key to the remote server:

ssh-copy-id -i username@ssh.server.ip
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
rev@192.168.100.6's password:

Number of key(s) added: 1

Login to the ssh server:

ssh username@ssh.server.ip

Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-27-generic i686)

Last login: Sun Jun 15 18:07:38 2014 from 192.168.100.7

No password was prompted.

To revert the changes, login to the remote SSH server and type:
ssh username@ssh.server.ip
rm -rf .ssh/authorized_keys

That’s it.

HowTo autologin to a remote server through SSH
Tagged on: