ngjiaquan
By:
ngjiaquan

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

June 22, 2017 174 views
DigitalOcean Backups Ubuntu 16.04

Hi all,

I was shifting some files under SFTP in .ssh and I had accidentally replaced the idrsa.pub in the server with my Mac Pro's idrsa.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.

3 Answers
SporkWitch June 22, 2017
Accepted Answer

The file on the server is '~/.ssh/authorizedkeys'; 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.

  • Stupid autoformatting, haha. The files above should be:

    ~/.ssh/authorized_keys
    id_rsa.pub
    

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

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

Have another answer? Share your knowledge.