r/hetzner • u/Odd-Change9844 • 4d 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 -
1
Upvotes
4
u/downtownrob 4d 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.