-- =======================================================================
-- COMMANDS
-- =======================================================================

[root@srv1 ~]# ssh-keygen -t rsa
[root@srv2 ~]# ssh-keygen -t rsa
[root@srv3 ~]# ssh-keygen -t rsa

[root@srv1 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[root@srv1 ~]# ssh srv2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[root@srv1 ~]# ssh srv3 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

[root@srv1 ~]# cat .ssh/authorized_keys
[root@srv1 ~]# scp .ssh/authorized_keys srv2:/root/.ssh/authorized_keys
[root@srv1 ~]# scp .ssh/authorized_keys srv3:/root/.ssh/authorized_keys

[root@srv1 ~]# chmod 644 ~/.ssh/authorized_keys
[root@srv2 ~]# chmod 644 ~/.ssh/authorized_keys
[root@srv3 ~]# chmod 644 ~/.ssh/authorized_keys

[root@srv1 ~]# ssh srv2 date
[root@srv1 ~]# ssh srv3 date
[root@srv1 ~]# date ; ssh srv2 date; ssh srv3 date;

-- =======================================================================
-- EXECUTION
-- =======================================================================

====================================================================================
[root@srv1 ~]# ssh-keygen -t rsa                                                   |
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:                                                            |                                                                  
6a:b6:d2:90:b4:d7:33:22:3e:08:4a:3d:65:12:8d:47 root@srv1.localdomain              |                                                                  
The key randomart image is:                                                        |                                                                  
+--[ RSA 2048]----+                                                                |                                                                  
|                 |	                                                               |                                                                  
|    ___          |		                                                           |                                                                  
|	(._.)         |                                                                |                                                                  
|	<||>          |                                                                |                                                                  
|	_/\_          |                                                                |                                                                  
+-----------------+                                                                |                                                                  
-----------------------------------------------------------------------------------|                                                                  
[root@srv2 ~]# ssh-keygen -t rsa                                                   |                                                                  
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:                                                            |                                                                  
55:59:cb:fe:28:21:93:49:01:4b:f1:6e:83:7d:62:6b root@srv2.localdomain              |                                                                  
The key randomart image is:                                                        |                                                                  
+--[ RSA 2048]----+                                                                |                                                                  
|                 |                                                                |                                                                  
|    /\_/\  (     |                                                                |                                                                  
|   ( ^.^ ) _)    |                                                                |                                                                  
|     \"/  (      |                                                                |                                                                  
|   ( | | )       |                                                                |                                                                  
|  (__d b__)      |                                                                |                                                                  
+-----------------+                                                                |
-----------------------------------------------------------------------------------|
[root@srv3 ~]# ssh-keygen -t rsa                                                   |
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:                                                            |                   
55:59:cb:fe:28:21:93:49:01:4b:f1:6e:83:7d:62:6b root@srv2.localdomain              |                   
The key randomart image is:                                                        |                   
+--[ RSA 2048]----+                                                                |                   
|      __         |                                                                |                   
|    _/  \_		  |                                                                |                   
|    ( `_ยด)       |                                                                |                   
|    <,=====> --- - -                                                              |                   
|    _/  \_       |                                                                |                   
+-----------------+                                                                |                   
===================================================================================|            
																									   
																									   
[root@srv1 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys                                         

[root@srv1 ~]# ssh srv2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host srv2 (192.168.56.72) can not be established.
RSA key fingerprint is 45:ca:cd:61:d5:d2:38:04:1c:10:1e:40:3d:8f:a9:68.
Are you sure you want to continue connecting (yes/no)? YES
Warning: Permanently added srv2,192.168.56.72 (RSA) to the list of known hosts.
root@srv2's password: *********

[root@srv1 ~]# cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtU4ml7DBNPqCE+OtaASEspVdMoB8A/ALmhH7Fv9/xZaRJa+cHNZuL1ArL0M7XQ== root@srv1.localdomain
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr0R0Ijxh9vYBfvsmH1tFpn5tV14MbwiwixOwPnT7sLVfrYZJj5AKehQn1N99UQ== root@srv2.localdomain
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA90R0Ijxh9vYBfvsmH1tFpn5tV14MbwiwixOwPnT7sLVfrYZJj5AKehQn1N99UQ== root@srv3.localdomain

[root@srv1 ~]# scp .ssh/authorized_keys srv2:/root/.ssh/authorized_keys
root@srv2 password: *********
authorized_keys                100%  806     0.8KB/s   00:00

[root@srv1 ~]# scp .ssh/authorized_keys srv3:/root/.ssh/authorized_keys
root@srv2 password: *********
authorized_keys                100%  806     0.8KB/s   00:00

[root@srv1 ~]# chmod 644 ~/.ssh/authorized_keys
[root@srv2 ~]# chmod 644 ~/.ssh/authorized_keys
[root@srv3 ~]# chmod 644 ~/.ssh/authorized_keys

-- =======================================================================
-- TEST
-- =======================================================================

[root@srv1 ~]# ssh srv2 date
Tue May 14 18:44:06 +04 2024

[root@srv1 ~]# date ; ssh srv2 date; ssh srv3 date;
Tue May 14 18:44:52 +04 2024
Tue May 14 18:44:52 +04 2024
Tue May 14 18:44:52 +04 2024

hostgator