OVH Cloud lost ssh key

Asphyxia

Owner
Administrator
Apr 25, 2015
1,844
2
2,197
327
Your SSH key was swallowed by ocean sharks, they craved your laptop SSD and your backup USB drive got V& by cyber SWAT.


  1. Reboot your OVH Cloud instance into rescue mode.
    1. 1577959522047.png
    2. 1577959552344.png
  2. Click your instance's name to view the dashboard and select "VNC console"
  3. 1577959633608.png Take note of your root password!
  4. Use PuTTY to enter your root session.
  5. Now we are going to automate all this shit with our custom .sh automation!
Run this stuff
Code:
rootpart=`lsblk --sort SIZE | grep "part" | tail -1 | cut -d " " -f 1`
mkdir /mnt/$rootpart
mount /dev/$rootpart /mnt/$rootpart
chroot /mnt/$rootpart

Awesome, now paste this in and run this to change root password:
Code:
passwd

Time to edit our sshd config:
Code:
cd /etc/ssh
nano sshd_config

Make sure to:
Code:
PermitRootLogin yes
PasswordAuthentication yes

---

Notice: If you want to replace an SSH key there are instructions here https://docs.ovh.com/ca/en/public-cloud/replacing_your_lost_ssh_key_pair/

I just honestly enjoy SSH'ing straight into the root account. Whenever I hear people say "Oh, you never want to SSH straight into root user.." I laugh my arse off. Why?

If someone hijacks your sudo user account you are f**ked, if someone hijacks your SSH key - also you are f**ked. No matter what, if you get hacked you are f**ked. If it's going to happen, it probably is just going to happen.

Sure there are things you can do to position yourself better, it comes down to this: keep patched, monitor critical logins, and be auditing whatever matters most to you.

Crawl with the basics, walk with the advanced, and run expertly.
 
Last edited:
Top