So I ran a command in the wrong directory, and changed the entire contents of my home directory on my server (including my ~/.ssh/authorized_keys file) to be owned by the media user…didn’t realize until after I had exited the SSH session. (The command was sudo chmod -R media:media ..) I was good and well locked out of my server after that.

Luckily, I run it as a VM in a Proxmox hypervisor, and this is the first time I am highly thankful for that fact.

Reference

(I need to revisit copy pasting into the noVNC/Spice/xterm.js console, I couldn’t figure it out and had some regrets about the password I created. Eventually I just logged in as root.)

Make sure the VM is shut down. Then from the Proxmox admin console:

# activate logical volume
lvchange -ay pve

# install package
apt install kpartx

# add mappings - not sure what exactly this is doing, but it makes
# the lvms accessible individually as 0p1 0p2 etc
kpartx -av /dev/mapper/pve-vm--101--disk-0

# mount the relevant "partition"
mkdir /mnt/recovery
mount /dev/mapper/pve-vm--101--disk-0p4 /mnt/recovery

Proceed to fix the permissions (sudo chmod -R XXXX:XXXX /mnt/recovery/home/user). Note that you will need to do it via numerical UID instead of username.

EOF