I recently set up a virtual server on Oracle Cloud using Ubuntu. I wanted to enhance security by changing the default SSH login port from 22 to 777 (or any random port). So, I went into /etc/ssh/sshd_config
and changed the Port 22
setting. Now, I’m unable to log back in via SSH, whether I try using the new port or the old one.
So can't use any commands... only the dashboard... which is a struggle in itself.
I’m using PuTTY for SSH access and have already contacted Oracle Cloud support. Unfortunately, their response was... unhelpful/useless/waste of time(to put it mildly) — they essentially just pointed me to basic Google search results, which I had already tried without success.
Has anyone else experienced this issue on Oracle Cloud’s free tier, or does anyone have advice on how to fix this? I didn’t take a backup (I know, my mistake, already feeling beyond stupid), and I really need to recover some important data from the server. Any suggestions would be greatly appreciated!
I found a solution to my problem, which involves using Oracle Cloud Shell to run commands directly. Here’s the process:
Replace
<target_instance_ocid>
with the new instance OCID and<boot_volume_ocid>
with the OCID of the old boot volume (The one you were locked out of), which can be found in the Oracle Cloud dashboard. When you run this command, it will successfully attach the boot volume to your new instance.After that, simply mount the old boot volume to a directory, and you’ll be able to access all its files and folders, make changes, or retrieve any data.
To do this follow these steps to access its files: (These commands are to be run on after connecting to the new instance you made and not in Oracle Cloud Shell like earlier commands)
lsblk
to list devices and find the new volume (e.g.,/dev/sdb
).sudo mkdir /mnt/boot-volume
to create a directory.sudo mount /dev/sdb1 /mnt/boot-volume
.cd /mnt/boot-volume
) and list files (ls
).This method works if you've lost your SFTP key, forgotten your password, or are unable to access the instance for any other reason. Good luck!