Non-interactive SSH login with SSH key

Why non-interactive? Simply because it allows for a machine to connect to another through SSH, without a user having to manually type in a password. Very useful for unattended connections.

Difficulty: easy

The ordinary SSH login process relies on a password entered when the destination address is reached. While this is fine when a user wants to access a remote machine, times happen when an unattended connection between two computers need to be achieved. Obviously I am quite sure there would be a program somewhere that would type the password automatically, but that would add yet another layer of complexity.

So the solution here is to rely on so-called authentication keys. If computers on both side of the SSH tunnel are trusted and not compromised, then authenticating through a key is more secure than using a password. A significant drawback though, if the key is lost or corrupted, through common hard drive failure, for example, there's no way to log in remotely into the server, especially if you disabled password login for increased security. Of course it can be mitigated with a proper backup plan.

On the computer that will initiate the connection:

$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/a/.ssh/id_rsa): Created directory '/home/a/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/a/.ssh/id_rsa.Your public key has been saved in /home/a/.ssh/id_rsa.pub.The key fingerprint is:3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Don't enter a passphrase! That would defeat the intention of having an unattended login process! And of course your key fingerprint will be different.

Now, login on the remote computer using normal password method, and add the generated public key to the list of authorized_keys.

ssh login@remote_computerlogin@remote_computer password:

The .ssh folder should be at the / folder with most common configurations. Just add the key using cat.