Root locked out of SSH

tarling asked:

I have tried to set up SFTP on a Debian machine, and was following instructions (and here) to prevent SFTP users from using remote login too.

But in doing so, it seems like I have locked root out from remote login too. Of course, without remote login, it seems like I am unable to fix this. It doesn’t look like telnet is enabled. My other, ftp only, users are chrooted.

Is there any way to fix this? I guess if I were able to restore my sshd_config file (backed up as /etc/ssh/sshd_config.bak), I may able to log in again, but how to gain access?

As you can tell from the nature of the question, I am a bit of a newbie at all this….

My answer:


Log in with your normal user account (the one for yourself, that you didn’t put in a chroot) and su to root, then you can fix the problem.

If you somehow managed to chroot your own user account, or never created one in the first place (don’t ever repeat this mistake) then you will have to get on the console, reboot to single user mode and recover it from the console.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.