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.

I used the command usermod -s /bin/fish root to change the root user's shell and now I can't login to my root account. Why is this happening?

I am trying to SSH into a server running Ubuntu through Putty on Windows. Getting a permission denied error.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

First off all, If you are still logged in via another shell: Do not log out.
(This is why you always test before logging out).

Secondly, can you still log on via another user?
Does that other user have (uid 0), then use that to check if /bin/fish is not only installed, but also present in /etc/shells (a list of allowed shells). If it is not, add it an try again.

If that user is allowed to use su or sudo try something like sudo /usr/local/bin/bash.

if all of that failed then you have to log in some other way. Tim's init=/bin/sh is the traditional solution for people with physical access to their servers. (An HP ILO or a DRAC from Dell will also serve as replacement for physical access).

From the LILO boot loader it this would be done with init=/bin/sh and followed by a mount -o remount,rw / after logging in. (else / would be read only, which would make correcting stuff hard). From grub select the option that lets you edit the kernel parameters. Add either a 1 (for run mode 1, aka single user) or 'single' to the end of the kernel parameters.

If none of these apply you will have to physically remove the disk and attacked it to an OS where you do have full access in order to correct it.

share|improve this answer
add comment

if the shell is not installed you are locked out immediately after login because the shell could not be loaded.

If you not use sudo and run linux you can pass a valid shell to the kernel in grub/lilo. Like:

init=/bin/sh 
share|improve this answer
    
please elaborate. how do i pass that command to the kernel using grub? –  moesef Feb 28 '13 at 20:51
    
At the grub boot menu, select the option that lets you edit the kernel parameters. Add either a '1' or 'single' to the end of the kernel parameters. That should drop you into single user mode. –  Hennes Feb 28 '13 at 20:54
    
"single" user mode is probably not enough, because it also tries to load the non existing shell. instead of single put init=/bin/sh at the end of the kernel line. Maybe you have to remount read-write your root fs to edit /etc/passwd –  Tim Haegele Feb 28 '13 at 21:00
add comment

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.