Thursday, May 11, 2023

SSH-Passwordless-Login-in-Linux

 

How to Setup SSH Passwordless Login in Linux [3 Easy Steps]


In this example, we will set up SSH password-less automatic login from server 192.168.0.12 as user server1 to 192.168.0.11 with user server2.

Step 1: Create Authentication SSH-Keygen Keys on – (192.168.0.12)

First login into server 192.168.0.12 with user server1 and 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/server1/.ssh/id_rsa): [Press enter key]
Created directory '/home/server1/.ssh'.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/server1/.ssh/id_rsa.
Your public key has been saved in /home/server1/.ssh/id_rsa.pub.
The key fingerprint is:
5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 server1@tecmint.com
The key's randomart image is:
+--[ RSA 2048]----+
|        ..oooE.++|
|         o. o.o  |
|          ..   . |
|         o  . . o|
|        S .  . + |
|       . .    . o|
|      . o o    ..|
|       + +       |
|        +.       |
+-----------------+

Step 2: Upload SSH Key to – 192.168.0.11

Use SSH from server 192.168.0.12 and upload a new generated public key (id_rsa.pub) on server 192.168.0.11 under server1 2 .ssh directory as a file name authorized_keys.

$ ssh-copy-id server2@192.168.0.11

Step 3: Test SSH Passwordless Login from 192.168.0.12

From now onwards you can log into 192.168.0.11 as server2 user from server 192.168.0.12 as a server1  user without a password.

$ ssh server1@192.168.0.11

No comments:

Post a Comment