Sshd_config file issue, not able to login, need urgent help.

Hello all,

By mistake i edited sshd_config file and made passwordauthentication no , Now i don't have key to login.
Is there any way, i can revert the changes, I am not able to login to the box at well.
Need help.

Thanks,
saurau

Hi,

Firstly is the box a production box, or do you have unrestricted access to the box i.e. can you shut it down. If you can the simplest way is bring it up in single user mode and regress the changes.

You could also boot the box from media mount up the file systems and edit the file.

Can you ftp or sftp onto the box with any kind of escalated privileges, where you could pull the config file off - edit locally and put back.

I'm sure that you now realise how important proper testing is in a situation like this.

Regards

Gull04

Another option is to look at your backups. If they run in a way that will allow you to recover the file without logging on (i.e. it has a service you can call) then you might have that as an option. I had the same issue when someone directly edited /etc/sudoers and left it unusable and no-one knew the root password - because there was no need.

I hope that this may help,
Robin

I would expect to start with physical access (console, ESX console etc.) to server since impacted is SSH config.
Log on console as a root, fix config + reload sshd.

1 Like