Sunday, February 2, 2020

Create SSH keys for newly provisioned instance in Oracle Cloud

Recently, we did a lift and shift of on premise EBS 12.2 to OCI using oracle Cloud manager and as part of it, the automation script provisioned two compute instance from the backup of the on premise instances.

Say the newly created two instance are A and B. Initially to connect to these two provisioned instances, we first go the cloud manager instance and from there we have to ssh to the newly created A instance/B instance from cloud manager using A's/B's private IP. So to connect to these two instances directly without going through the cloud manager, we need the private keys if we are connecting via putty. In this blog, i will explain how we can create the new ssh keys and convert them to PPK format using puttygen in windows.

In Compute instance A/B

generate the ssh keys.

ssh-keygen

Accept the default values.

Once it completes, you will be able to see two files
id_rsa.pub
id_rsa

Now copy the content of id_rsa.pub to the authorized_keys.
cat id_rsa.pub >>authorized_keys

The above steps are for opc user.

ssh <private ip of A>

Now for Oracle user.

opc>hostname   sudo su - oracle

and follow the above steps for generating the rsa keys and adding the contents to the authorized keys.




The server part is complete. Now in order to connect to the server, we need the private ppk keys. Putty doesn't recognize the rsa keys. They have to converted to ppk format.


Copy the id_rsa to the windows and using puttygen, convert it to putty format.

open puttygen

click on Conversions and import key
choose the rsa file



       
and save it. It is important in terms with security to provide the passphrase.


Once we have the private key, we can go to putty and connect to the instance using this key





   Hope this helps someone. Happy learning cloud.



No comments:

Post a Comment