In this demo, we will establish ssh connectivity between 2 servers called

riyadh1

riyadh2

 

On riyadh1 :

[root@riyadh1 ~]# su - oracle
[oracle@riyadh1 ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(vboxsf)

[oracle@riyadh1 ~]$ chmod 700 ~/.ssh

[oracle@riyadh1 ~]$  /usr/bin/ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
6b:54:21:58:c2:7b:9a:9f:e2:ac:b9:98:bf:15:66:02 oracle@riyadh1.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|     ..oo .      |
|      o. . .     |
|  E    .  .      |
|   .  . ..       |
|    . ++S        |
|     +oo .       |
|      ..o.       |
|   o +..o        |
|  o.*=o.         |
+-----------------+
[oracle@riyadh1 ~]$

when it will ask for  inputs , just press enter. don’t give anything.

Lets do the same operation on other server.

 

On Riyadh2:

[oracle@riyadh2 ~]$ chmod 700 ~/.ssh

[oracle@riyadh2 ~]$ /usr/bin/ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
6b:5b:ff:22:b7:0f:34:91:22:37:5c:8b:84:71:33:5e oracle@riyadh2.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|        .o= E    |
|        .= * o   |
|        . B +    |
|         o o .   |
|        S   o    |
|         . . .   |
|        o . .    |
|       . o..o.   |
|        .  oo=o  |
+-----------------+

Again on riyadh1:

[oracle@riyadh1 ~]$ cd ~/.ssh

[oracle@riyadh1 .ssh]$ cat id_rsa.pub >> authorized_keys

[oracle@riyadh1 .ssh]$ scp authorized_keys riyadh2:/home/oracle/.ssh
The authenticity of host 'riyadh2 (192.168.100.26)' can't be established.
RSA key fingerprint is 6b:e4:a5:ef:a6:89:62:76:25:43:13:aa:49:ed:30:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'riyadh2,192.168.100.26' (RSA) to the list of known hosts.
oracle@riyadh2's password: 
authorized_keys                                                100%  408     0.4KB/s   00:00

On riyadh2:

[oracle@riyadh2 ~]$ cd ~/.ssh
[oracle@riyadh2 .ssh]$ cat id_rsa.pub >> authorized_keys

[oracle@riyadh2 .ssh]$ scp authorized_keys riyadh1:/home/oracle/.ssh
The authenticity of host 'riyadh1 (192.168.100.25)' can't be established.
RSA key fingerprint is 6b:e4:a5:ef:a6:89:62:76:25:43:13:aa:49:ed:30:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'riyadh1,192.168.100.25' (RSA) to the list of known hosts.
oracle@riyadh1's password: 
authorized_keys                               100%  816     0.8KB/s   00:00   

Now enable self ssh:

 

On riyadh1:

 

[oracle@riyadh1 .ssh]$ ssh riyadh1
The authenticity of host 'riyadh1 (192.168.100.25)' can't be established.
RSA key fingerprint is 6b:e4:a5:ef:a6:89:62:76:25:43:13:aa:49:ed:30:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'riyadh1,192.168.100.25' (RSA) to the list of known hosts.

On Riyadh2:

[oracle@riyadh2 .ssh]$ ssh riyadh2
The authenticity of host 'riyadh2 (192.168.100.26)' can't be established.
RSA key fingerprint is 6b:e4:a5:ef:a6:89:62:76:25:43:13:aa:49:ed:30:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'riyadh2,192.168.100.26' (RSA) to the list of known hosts.

Test ssh connectivity:

[oracle@riyadh1 ~]$ ssh riyadh1 date
Wed Mar 18 14:33:07 EDT 2015
[oracle@riyadh1 ~]$ ssh riyadh2 date
Wed Mar 18 14:33:10 EDT 2015
[oracle@riyadh2 ~]$ ssh riyadh1 date
Wed Mar 18 14:33:25 EDT 2015
[oracle@riyadh2 ~]$ ssh riyadh2 date
Wed Mar 18 14:33:27 EDT 2015