I have recently had the displeasure of getting locked out of my Oracle Cloud VPS due to my chosen SSH port becoming unreachable. I still don’t know why this happened, as I hadn’t changed anything. There’s no firewall on the server, and everything is allowed in the ingress rules. But don’t tell any hackers that.
Regardless of why it happened, I had to fix it, and the solutions I found were far from ideal. I even submitted a support request, and after a few hours we ended up at the option of creating another VPS and mounting the old one’s drive to fix it.
That’s not what I ended up doing. Instead, I found this comment by RenĂ© Fennet and got to work. It didn’t quite work out as he had written, but I don’t see how to add a comment on that page so I’ll make a post here instead.
While Oracle does provide an online shell into the server, the account is by default configured to only use an SSH key. So when prompted for a username and password, it’s impossible to provide details that the computer is satisfied with, as there isn’t a password to enter into the field (and leaving it blank isn’t a solution).
Unless you had set up an account that has a user password, you need to go through a complete charade to get back in:
- From the Oracle dashboard, go to your compute instance.
- Scroll down, and on the left-hand side you’ll see a menu containing “Console connection”.
- “Launch Cloud Shell connection”
- Once connected, click “Reboot” at the top of the page. Confirm “Reboot instance”.
- Wait 40-50 seconds for the console to clear. When it does so, mash the F2 key.
- If you failed to get into the BIOS, wait 10-20 seconds for the login screen to appear, then reboot the machine again and retry.
- Select “Continue” in the BIOS then immediately press Esc followed by another key. I chose Q — any key unlikely to perform an action will do. There is something odd about how the shell accepts inputs, and pressing another key helps push the previous one through.
- If you press Esc too late, more than once, or failed to quickly follow it by another keystroke, click “Reboot” again and check the box that forces it to reboot (otherwise you’ll have to wait 15 minutes, as the system doesn’t respond to reboot commands when in GRUB).
- Go to “Advanced options” and boot into recovery mode.
- When prompted, press Ctrl+D.
- You should now be logged in as root. Make whatever changes you need to. In my case,
nano /etc/ssh/sshd_config
to change SSH port andrm /usr/local/bin/endlessh
to kill endlessh. - Reboot, either using the reboot button or by typing the
reboot
command.
Since this website and all is still being hosted by Oracle, I should stress that it’s okay for hosting, considering the free tier. It’s just a bit complicated, that’s all.