Debian – ssh root access denied after changing shell

debianpasswdrootshell

after i tried to change my server shell, i cannot login as root anymore.

First, i installed the z-shell (zsh) as root and then i wanted to change it to my default shell. Therefore i used "chsh". My fault was, that i typed in a wrong path. After logout and new login via Putty, i got the message "Access denied".

It was foreseeable, when the path to the shell doesn't exist. So i logged in into my control panel, and changed the /etc/passwd file via filemanager: I corrected the wrong last part of the first line – the root user:

root:x:0:0:root:/root:/usr/bin/zsh

Even if i change it to the old shell /bin/bash or /bin/sh it doesn't work. I read that passwd & shadow are no live-files, so i restarted the server, but still same problem

Any ideas, what else i could do?

OS: Debian 5 + Parallels Plesk 11

Best Answer

  1. Always use vipw to edit /etc/passwd, and vipw -s to edit /etc/shadow.
  2. Check that the shells you're trying to use are listed in /etc/shells.
  3. Check that SElinux is not set to 'enforcing' in /etc/selinux/config. Change it to 'permissive' or 'disabled'. [requires reboot]
  4. When you want to try a new shell don't log out to test it. Start up an additional SSH session or tty, and leave the current one running in case you f*ck it up.
  5. Check your logs for errors relevant to the login process that might indicate what else is wrong.

If you still can't fix it on your own, then contact your hosting provider. They will either know how to fix it inside of 10 minutes, or you should find a better host.

Related Topic