SSH port mistakes with Oracle Cloud

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:

  1. From the Oracle dashboard, go to your compute instance.
  2. Scroll down, and on the left-hand side you’ll see a menu containing “Console connection”.
  3. “Launch Cloud Shell connection”
  4. Once connected, click “Reboot” at the top of the page. Confirm “Reboot instance”.
  5. Wait 40-50 seconds for the console to clear. When it does so, mash the F2 key.
  6. 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.
  7. 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.
  8. 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).
  9. Go to “Advanced options” and boot into recovery mode.
  10. When prompted, press Ctrl+D.
  11. 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 and rm /usr/local/bin/endlessh to kill endlessh.
  12. 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.