SSH stands for Secure Shell. We connect remote host to interact in Linux console every now and then during daily operation. We often called passwordless SSH for key based authentication. In this post we are going to see how this can be done.
Following are the advantages of passwordless SSH in Linux.
- End user need not have to type a password whenever he/she try to login to remote host.
- It’s more secure as this works on public and private key cryptography.
- Easy to maintain for both small and large infrastructure.
- To automate tasks like copy or syncing files and folders, taking backup and executing scripts.
Our testing Setup
172.24.24.231 – Client
172.24.24.191 – Remote Host
User – Oracle
To start with: we need to generate a public & Private key on the Client Host.
Cautious: Take a backup of authorized_keys file from .ssh folder before generating keys and keep it in safe place, this will override with the current one and follow the below steps.
Also Read: Red Hat Enterprise Linux 8.1 Installation with Screenshots
Also Read: CentOS Linux 8 Installation With Screenshots
Step 1:
Login into client host and generate public and private key using below command.
# ssh-keygen -t rsa
Option “-t” for type and RSA is the protocol for key generation and default key is 2048 bits. You can change the default key value of your choice mentioning with option “-b” and value of key.
This will create .ssh directory in user’s home directory and generates the public and private key.
.ssh/id_rsa – Private key
.ssh/id_rsa_pub – Public key
Step 2:
Copy the public key to remote host for passwordless SSH using ssh-copy-id command. This will copy public key to remote host on authorized_keys file.
# ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@172.24.24.191
Above command will copy public key to remote host in authorized_keys file under .ssh folder. Verify whether public key is copied on remote host.
Step 3:
Testing passwordless SSH
After copy public key to remote host you should be able to login to the remote server without prompting password.
[oracle@teclues ~]$ ssh oracle@172.24.24.191
Conclusion: In this tutorial, passwordless SSH in Linux. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!