SSH (Secure SHELL) is an open-source and most trusted network protocol that is used to log in to remote servers for the execution of commands and programs.
In this article, we will see that how to set up password-less ssh on Linux using ssh keys to connect to remote Linux servers without entering a password.
I have the following environment:
Client System : 10.0.2.5
Remote System : 10.0.2.15
In this example, we will set up password-less automatic ssh login from system 10.0.2.5 to 10.0.2.15 with user steve.
Step 1: Create Authentication SSH-Keygen Keys on Client System
Considering that you are already logged in on the client system. Now generate a pair of public keys using the following command:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/steve/.ssh/id_rsa):[Press Enter]
Enter passphrase (empty for no passphrase):[Press Enter]
Enter same passphrase again:[Press Enter]
Your identification has been saved in /home/steve/.ssh/id_rsa
Your public key has been saved in /home/steve/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:YMOI1KqZUiBZnn2JZQqgn4e08K2Arp9LGQkpJjP37Ec [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|.++. o |
|=+ =.B . |
|@o*.= B |
|=XoO o o |
|o=O = E S |
|*. * . |
|..+ . . |
|.. . . |
|..+. |
+----[SHA256]-----+
Step 2: Upload SSH Key to Remote System
You can use ssh-copy-id to upload the new generated public key (id_rsa.pub) on system 10.0.2.5 under remote system’s .ssh directory as a file name authorized_keys.
ssh-copy-id [email protected]
Test passwordless SSH Login from Client System
From now onwards you can login to 10.0.2.15 from 10.0.2.5 without a password.
ssh [email protected]