Pages

Thursday 24 October 2013

Configure SSH Keys for RAC on Linux to establish user equivalance

1.Configure SSH on each node in the cluster. Log in as the "oracle" user and perform the following tasks on each RAC node.

[oracle@test4202 ~]$ mkdir ~/.ssh
[oracle@test4202 ~]$ ls -lart
total 28
-rw-r--r--  1 oracle oinstall  124 Oct  8 12:41 .bashrc
-rw-r--r--  1 oracle oinstall  176 Oct  8 12:41 .bash_profile
-rw-r--r--  1 oracle oinstall   33 Oct  8 12:41 .bash_logout
drwxr-xr-x 14 root   root     4096 Oct 24 08:55 ..
-rw-------  1 oracle oinstall 1736 Oct 24 09:05 .bash_history
drwxr-xr-x  2 oracle oinstall 4096 Oct 24 10:12 .ssh
drwx------  3 oracle oinstall 4096 Oct 24 10:12 .
[oracle@test4202 ~]$ chmod 700 ~/.ssh
[oracle@test4202 ~]$ /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:
2e:83:65:b5:c6:0d:11:b1:db:a6:a5:98:bd:85:6d:25 oracle@test4202
The key's randomart image is:
+--[ RSA 2048]----+
|        +o       |
|         o       |
|        +        |
|       o *       |
|      o S E .    |
|     + * B o     |
|    . = * +      |
|       o +       |
|        .        |
+-----------------+
[oracle@test4202 ~]$ cd /home/oracle/.ssh/
[oracle@test4202 .ssh]$ ls -lrt
total 8
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:13 id_rsa.pub
-rw------- 1 oracle oinstall 1675 Oct 24 10:13 id_rsa


Note:The RSA public key is written to the ~/.ssh/id_rsa.pub file and the private key to the ~/.ssh/id_rsa file.


2.Generate authorized_keys

Log in as "oracle" user on node1, generate an "authorized_keys" file on node1 and then copy it to node2 as below.

cd /home/oracle/.ssh/

[oracle@test4201 .ssh]$ ls -lrt
total 8
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:10 id_rsa.pub
-rw------- 1 oracle oinstall 1675 Oct 24 10:10 id_rsa
[oracle@test4201 .ssh]$ cat id_rsa.pub >> authorized_keys
[oracle@test4201 .ssh]$ ls -lrt
total 12
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:10 id_rsa.pub
-rw------- 1 oracle oinstall 1675 Oct 24 10:10 id_rsa
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:11 authorized_keys
[oracle@test4201 .ssh]$ scp authorized_keys oracle@test4202:/home/oracle/.ssh/
Password:
authorized_keys                                                                                                                                          100%  398     0.4KB/s   0.4KB/s   00:00

Next, log in as the "oracle" user on node2 and perform as below.

[oracle@test4202 tmp]$ cd /home/oracle/.ssh/
[oracle@test4202 .ssh]$ ls -rlt
total 12
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:13 id_rsa.pub
-rw------- 1 oracle oinstall 1675 Oct 24 10:13 id_rsa
-rw-r--r-- 1 oracle oinstall  398 Oct 24 10:14 authorized_keys
[oracle@test4202 .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0iKAmCxhxPJg+VLCHZuSzvix74Dw79ze5UJdx54hTfQ70Z/orYrTrOimSf0INSqBmqpiofTqu8W0Wu9acGtunsdJe++f2Ew58slF8svHCXaKyIMxBQheg7uCKEoDaaXbiZAD/30fGKAO5nL5IVZd9Pc7TVufutZbwGknbZxKwIXoFOUFDW3D0EkMiuFFiItWNjLoQvAx84hW5wJ2ImWc0mOSt2NDTk2O4pZ7plxeEYqr2Gy/bTwNba40r1ig7fwsRHh1j1t/cRYxY2s9IqlZeISynb6NaE4PmNHINypfuXb8f8kPt/g/GU8hsW8gbTBsnZPKDr+tdEDQjbnFk1eYjQ== oracle@test4201
[oracle@test4202 .ssh]$ cat id_rsa.pub >> authorized_keys
[oracle@test4202 .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0iKAmCxhxPJg+VLCHZuSzvix74Dw79ze5UJdx54hTfQ70Z/orYrTrOimSf0INSqBmqpiofTqu8W0Wu9acGtunsdJe++f2Ew58slF8svHCXaKyIMxBQheg7uCKEoDaaXbiZAD/30fGKAO5nL5IVZd9Pc7TVufutZbwGknbZxKwIXoFOUFDW3D0EkMiuFFiItWNjLoQvAx84hW5wJ2ImWc0mOSt2NDTk2O4pZ7plxeEYqr2Gy/bTwNba40r1ig7fwsRHh1j1t/cRYxY2s9IqlZeISynb6NaE4PmNHINypfuXb8f8kPt/g/GU8hsW8gbTBsnZPKDr+tdEDQjbnFk1eYjQ== oracle@test4201
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtdMGC7W1aGAyKuxR5HO2JsTprL3INqp4AGw5uBS3OyeA0pyrfqA+zB7MTxBTi7apJYqaGdVpTsmdawGQ46JQbfXu6Ob78KsQDHdJupzeSw5iBmCcsnzZ54LE/8Qv5FIh9R8HQH8Z/Yx69CfeRK8jPBPOPqdw9rHUhbpoy6u5PZhFgApEZyKM3IYqAU+ty/4lzeDAf/y+uBwK5kSRWzs5fAoSrWjzhyrzNERqN22pN8+OyYm295IPi2cDRb7NnInZdqfrTzWHpwzqrJL/88GTFWkgpC8oJp9sVl/v5KAJtnQCaXpyOsZraNwcZxyO07tIJLFcW0PPNMyk46vegO4tmw== oracle@test4202



[oracle@test4202 .ssh]$ scp authorized_keys oracle@test4201:/home/oracle/.ssh/
The authenticity of host 'test4201 (152.69.88.127)' can't be established.
RSA key fingerprint is a4:a5:a8:ef:6f:72:b1:02:ae:f5:27:9c:2f:a4:4c:16.
Are you sure you want to continue connecting (yes/no)? yes
Password:
authorized_keys                                                                                                                                          100%  796     0.8KB/s   0.8KB/s   00:00


3.Test the setup as below

Node1
[oracle@test4201 .ssh]$ ssh test4201 date
The authenticity of host 'test4201 (152.69.88.127)' can't be established.
RSA key fingerprint is a4:a5:a8:ef:6f:72:b1:02:ae:f5:27:9c:2f:a4:4c:16.
Are you sure you want to continue connecting (yes/no)? yes
Thu Oct 24 10:17:15 PDT 2013
[oracle@test4201 .ssh]$ ssh test4202 date
Thu Oct 24 10:17:29 PDT 2013
[oracle@test4201 .ssh]$


Node2
[oracle@test4201 .ssh]$ ssh test4201 date
The authenticity of host 'test4201 (152.69.88.127)' can't be established.
RSA key fingerprint is a4:a5:a8:ef:6f:72:b1:02:ae:f5:27:9c:2f:a4:4c:16.
Are you sure you want to continue connecting (yes/no)? yes
Thu Oct 24 10:17:15 PDT 2013
[oracle@test4201 .ssh]$ ssh test4202 date
Thu Oct 24 10:17:29 PDT 2013
[oracle@test4201 .ssh]$

Note:  You can also run the sshUserSetup.sh script available at /grid/sshsetup to setup user equivalance

No comments:

Post a Comment