In today’s post, will see how to add new public key to the OCI instance which was already created.
Followed the document https://docs.cloud.oracle.com/iaas/Content/Compute/References/serialconsole.htm
- Create a new pair of Public and Private key pair require to upload using PUTTYGEN.
- 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.
- Now, go the OCI instance and click on console connection and create a one using the public key generated in Git or linux server.
- Once, the console connection is active, click on connect SSH, copy the command and paste in the Git or linux server.
- After pasting the command supply the password of the key and it will connect remotley to the OCI instance.
- Now, go to OCI instance GUI, reboot the system and edit the kernel to start in bash prompt.
- Once you get in to bash prompt edit the authorized keys of the OPC user and restart the machine.
- 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.