• Create RSA Key pair for accessing SSH Service

[root@testserver01 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:vMHPH+3nf7O5Twod0/NVMAxBCEoIoindeYLp+IRPH7s root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|. .. .. .. o++o  |
|.+ +.o .  .   .o |
|+ + + o         .|
|.+ . o o       ..|
|o = .   S     o.o|
| = o .   =   o o+|
|  E .   . o o o o|
|           . + ++|
|            . o*@|
+----[SHA256]-----+
[root@testserver01 ~]# 

  • Copy SSH Public key to Connecting Server

[root@testserver01 ~]#  ssh-copy-id -i ~/.ssh/id_rsa user@testserver02
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.20.100 (192.168.20.100)' can't be established.
ECDSA key fingerprint is SHA256:fb3pJRh6JyaIN26+chtQ/TCbDsZkHtda8rd6CjdyQRs.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/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
user@192.168.20.100's password: <password>

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'user@192.168.20.100'"
and check to make sure that only the key(s) you wanted were added.

  • Connect Server2 with out Password

[root@testserver01 ~]# ssh user@testserver02
Last login: Wed Nov 30 10:03:05 2022 from testserver01
[user@testserver02~]$

 

 

Technology