Back to Blog

Recover lost access to OCI server - lost passwrod for RSA key

   Mariusz Antonik    Oracle Cloud (OCI)    2 min read    2 views

Idea to recover access to serve is to change RSA key 

We will try to login to server when it boot, and get access to single user mode.

After you setup the connection to console - restart server 

at startup press F12 to get list of kernels available 

YOu may see this screen 

 

Then select Continue 

on next screen select kernel and press e

 

  • Next, select the Kernel version from the grub menu item and press e key to edit the first boot option. Now use the Down arrow key to find the kernel line (starts with “linuxefi“), then at the end of the line add the argument "rw init=/sysroot/bin/sh" as shown in the screen shot below

 

 

press Ctlr + x

 

 

after login execute 

chroot /sysroot/

now /home folder is available and we can change ssh key 

 

now you can edit this file 

vi authrized_keys

get your new public key and past to this file then reboot

 

 

At end of the file add empty line #end

once you done reboot server 

reboot -f

Change passwrod for root, or opc account 

passwd root

passwd opc

If you have some issies with server - check also selinux, check /var/log/messages and see if something is not correct. Sometimes SELINUX may block your access causing you a problem. Disable it, recover access to server and then enable it again 

 

 

 

 

 

 

 

Tags: #OCI