Adding Public SSH key in Oracle Cloud Infrastructure Gen 2 !!

Hi Guys,

In today’s post, will see how to add new public key to the OCI instance which was already created.

Followed the document

High-level Steps:

  1. Create a new pair of Public and Private key pair require to upload using PUTTYGEN.
  2. Install Git or if you have a linux server, go the server and by using ssh-keygen create the public and private key which will be used in the console connection of the OCI instance.
  3. Now, go the OCI instance and click on console connection and create a one using the public key generated in Git or linux server.
  4. Once, the console connection is active, click on connect SSH, copy the command and paste in the Git or linux server.
  5. After pasting the command supply the password of the key and it will connect remotley to the OCI instance.
  6. Now, go to OCI instance GUI, reboot the system and edit the kernel to start in bash prompt.
  7. Once you get in to bash prompt edit the authorized keys of the OPC user and restart the machine.
  8. After restarting machine try to connect with the private key(which was assoicated with public key generated through PUTTYGEN) it should have to connect successfully.


Using the below link, please create key pair using PUTTYGEN.

Below is my instance to which I upload the new key:

In my case I’m using a Linux test server instead of Git and try to create the keys to create console connection.

Once console connection is active, click Connect with SSH and copy the command to execute in linux test server.

Successfully connected remotely to the OCI instance.

Reboot the OCI instance.

Select the kernel and hit ‘E’ to edit the kernel to run with bash prompt.

Editing the kernel using rw init=/bin/bash and press ctrl+x, which it will land on bash prompt.

Execute the below commands and update the new public key generated through PUTTYGEN to authorized_keys

Copy the new key to the authorized_keys file save it.

Change the ownership and permissions of authorized_keys file and reboot the system.

Now, connect to OCI instance with new private key, it should have to connect successfully.

Hope this post find’s you well !!

Happy learning !!

Firoz Hussain K.

  1. Posted by Manjula
    • Posted by manjula
      • Posted by hussaindba
        • Posted by Manjula
    • Posted by hussaindba
  2. Posted by Kd
    • Posted by hussaindba
  3. Posted by 4thdays
  4. Posted by George
    • Posted by hussaindba
  5. Posted by Aaron
  6. Posted by Anupriya
  7. Posted by Leopold Gault
  8. Posted by Tiago de Aviz
    • Posted by hussaindba

Add Your Comment