Question

Accidentally replaced id_rsa.pub in .ssh root, unable to connect to server.

Hi all,

I was shifting some files under SFTP in .ssh and I had accidentally replaced the id_rsa.pub in the server with my Mac Pro’s id_rsa.pub. Now I cannot connect to my server via ssh and console!

I have tried running the image backup but it does not seem to do any changes in regards to server settings.

What should I do? I have two sites hosted there and both are down.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

The file on the server is ‘~/.ssh/authorized_keys’; you put your idrsa.pub in this (typically a server wouldn’t even have an idrsa.pub on it, at least not for a user account).

Console access from the DO web interface is a local terminal, so you would need to use local authentication. If you did not set a passphrase (if you preloaded your keys when creating it, there is no password set, password auth is disabled), then you would not be able to get in. There should be an option in the web interface to reset the root password; attempt this, then login via console using that password. Change that password, fix your settings, and you should be good to go.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I am not sure - I had run mysql_secure_installation before that too. After that, it keeps displaying this error : packet_write_wait: Connection to 128.199.112.177 port 22: Broken pipe

Why can’t you connect via SSH and console? id_rsa.pub server-side has nothing to do with that.