Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
1  
Can you ssh or sudo and execute a command? ( /bin/sh would be a good command ) –  Hennes Feb 20 '13 at 19:16
    
No, sadly not. Until now, there was just the root user (from my side) and other users from parallels plesk i can't use. I'm only able to edit files using the file manager in the control panel. –  tobias b. Feb 20 '13 at 19:21
2  
Do you have console access to the server? If so, try booting it into single user mode, and then do the troubleshooting. start with chsh -s /bin/bash root –  Daniel t. Feb 20 '13 at 19:23
    
see comment above: no console access. –  tobias b. Feb 20 '13 at 19:24
    
Does the server have a remote control card? (Dell DRAC, HP ILO, ...) or is it a VPS? In the latter case: Either ask the local people to help or reinstall. Also test from another console before logging out. Ditto for changes to .profile etc etc –  Hennes Feb 20 '13 at 19:26

2 Answers 2

  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.

share|improve this answer
2  
+1 for the "don't log out to test it." –  Hennes Feb 20 '13 at 19:39
    
Indeed very good hints! I will keep them in mind next time. I'm pretty sure that the check of the auth log file provided the error: 'User root not allowed because shell /bin/sh\r does not exist' But i'm not sure how to edit this, because of the limited possibilities. One solution might be to contact my hosting provider (as you said) to let them help me. Maybe one last stupid question: Would it help to access the editor from a linux system instead of windows? Or is there no difference, because of the access via http? –  tobias b. Feb 20 '13 at 20:54
    
@tobiasb. it's a tossup whether or not it would work or not via a Linux-based browser. It could be Windows sending a \r\n through the web interface, or it could be the WYSIWYG using \r\n for all line breaks. Can't hurt to try. –  Sammitch Feb 20 '13 at 20:59
    
@Hennes sadly, most of us don't learn about this one until after we do it. –  Sammitch Feb 20 '13 at 21:00
    
Aye. Or until someone sitting next to you messes it up and thus teaches by example. In my case I was the lucky fellow. –  Hennes Feb 20 '13 at 21:02
up vote 0 down vote accepted

I found a solution in another Forum. For all people with the same problem, perhaps this approach can help as well:

My provider changed the root password and tried the "chsh -s /bin/bash root" which didn't work, because the password was not accepted and the following error occured: "chsh: PAM authentication failed".

dave_mystic gave the solution:

The real problem is in /etc/pam.d/chsh. In that file, the line which prevents users from changing back to a normal shell after being assigned a special shell appears before the line that authorizes all changes from the root.

Unfortunately, the following line was firing first, disallowing a change because the users shell was NOT in the list of available shells. The authorization line from me being 'root' via sudo never fired because it was never checked after the first line fired.

auth required pam_shells.so

The solution was to temporarily comment out the line in /etc/pam.d/chsh, change the users shell to the correct shell, and then remove the comment in the line.

Source: http://ubuntuforums.org/showthread.php?t=1702833

So i commented out the mentioned line and after that i was able to change the shell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.