“You lost the SSH private key to an instance. How to access it again? method 01”.
Long version #
Losing an SSH key can be problematic and troubling. However, on OCI, it is simple to add another key to the opc user’s authorized_keys file. Follow the instructions below to regain SSH access.
Jump to TLDR for instructions.
The new SSH key will be appended to the authorized_keys file.
Be aware of the following potential issues when deleting the instance:
- If the instance is not using a reserved IP, the IP will be recycled.
- Creating a new instance can be challenging if you are using an always-free tenancy.
TLDR #
- Delete the instance, preserving the boot volume.
- Recreate the instance using the boot volume of the deleted instance.
- Add the new SSH key in the SSH key section.
You should now be able to SSH into the instance again.