I've basically locked myself out of my vps. There's nothing on it, so there's not too much worry, but I really want to know how to fix the problem.

I've locked myself out by disabling root access, and then overwriting id_rsa. I've learned my lesson, and will be naming all my key pairs from now on.

Anyway, whenever I attempt to logon via ssh

ssh username@xxx -p 2222

I get this:

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
Received disconnect from xxxxx: 2: Too many authentication failures for root

The problem is I no longer have a valid key, so my ssh agent offers each one in turn, until the server ignores me.

I can easily generate another key pair locally, but I'm confused as to what to do on the server side of things?

I have root access via a cloud console.


If you can paste text into your console, you can paste the public key of the new keypair into the /root/.ssh/authorized_keys file of your VPS.

SSH keys are asymmetric public/private keys, so you only need the public key to be on the machine you're connecting to. The private key stays on the machine you're connecting from.

To view your newly-generated keypair's public key, you can cat the id_rsa.pub file that should be created automatically (that is if you use the ssh-keygen command to generate your new keypair).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.