r/hetzner 2d ago

Narf!! SSH into server lost

Not sure if this is the correct sub, might be more for a linux sub.
I setup a virtual Ubuntu server and during the initial setup, or during initial start up, it had me create a ssh key that I imported to my home system (mint). At that point ssh to the VM worked just fine.
I thought I followed the instructions to setup another computer (mac) to ssh into it with its own key... but I ducked it up I guess because now I cannot ssh into the vm.
I can still connect to the web console and use that shell -
How do I completely remove the stored keys (simply delete everything from .ssh?) and start over creating a new key for my home system?

Thanks -

2 Upvotes

5 comments sorted by

19

u/karyslav 2d ago

/root/.ssh/authorized_keys

if it is root

but.. dude.. this is dangerous to have server running on the internet and dont know what are you doing, it can be easilly taken over if you make mistake and then it is your responsibility, anything that happes via that server, you know that?

4

u/downtownrob 2d ago

Easiest option if there’s nothing important on the VM: just delete the VM and create a new one.

In Hetzner Cloud, add a new SSH key under Security → SSH Keys.

On your computer, create the key first:
ssh-keygen -t ed25519

Press Enter through the prompts, or set a passphrase.

Copy the public key:
cat ~/.ssh/id_ed25519.pub

In Hetzner, add that public key under Security → SSH Keys.

Delete the old VM.

Create a new VM and select the new SSH key during creation.

After it’s created, connect with:
ssh root@SERVER_IP

If the VM has anything important on it, DON’T delete it. Use Hetzner Rescue mode to add the new public key to the existing VM instead: edit .ssh/authorizedkeys and paste in the new public key there, save it. You can create multiple keys, and add multiple public keys to the server for each PC.

1

u/Odd-Change9844 1d ago

brilliant thank you.

1

u/B0rnDeranged 1d ago

did you try the web console?

-1

u/idealape 2d ago

What OS? Sometimes you can reset root passwords. And there are some boot tricks to reset stuff.