LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Root ShelI Change - changed /etc/passwd /sbin/sh to /sbin/bash and gave No Shell (http://www.linuxquestions.org/questions/solaris-opensolaris-20/root-sheli-change-changed-etc-passwd-sbin-sh-to-sbin-bash-and-gave-no-shell-801177/)

mn35 04-10-2010 02:14 AM

Root ShelI Change - changed /etc/passwd /sbin/sh to /sbin/bash and gave No Shell
 
Dear Sirs,
I was troublshooting something about crontab, and I got carried away and went to /etc/passwd and changed /sbin/sh to /sbin/bash of root...
DUUHHH, /sbin/bash does NOT exist so when i tried to log in again it gave me, No Shell, and exits.

I have a Solaris 8, i have other login but it is NOT Super-User -admin. I wanted to add a script in /sbin named bash that would run /bin/sh just to bypass the issue but no permission on /sbin ( and obviously no permission on /etc/passwd ).

I read how would Solaris 10 fallback to /sbin/sh if 'No Shell' problem. But does Solaris 8 do the same ??

Is there any way to undo that? any way around it??

Please H.E.L.P.

regards.

-----------------------------------------
Life is about relativity of expectations.

bathory 04-10-2010 04:20 AM

Hi,

You should boot from the Solaris cdrom and then mount the / partition, so you can edit /etc/passwd and undo the changes

Regards

catkin 04-10-2010 06:17 AM

Quote:

Originally Posted by bathory (Post 3930753)
Hi,

You should boot from the Solaris cdrom and then mount the / partition, so you can edit /etc/passwd and undo the changes

Regards

IDK Solaris but is it not possible to log in as a non-root user and then use su to assume root privileges while continuing to use the non-root user's shell?

choogendyk 04-10-2010 08:59 AM

Catkin,

Interesting. But I don't think it's going to work. I'm not going to mess up one of my root logins to see, but I did try it on another login. For example, the sasl account has /dev/null as its "shell" on one of my systems (Solaris 9, I don't have any 8 anymore). When I tried (from root) to `su sasl`, I got the reply "su: No shell" and was left at root.

catkin 04-10-2010 03:45 PM

Quote:

Originally Posted by choogendyk (Post 3930939)
Catkin,

Interesting. But I don't think it's going to work. I'm not going to mess up one of my root logins to see, but I did try it on another login. For example, the sasl account has /dev/null as its "shell" on one of my systems (Solaris 9, I don't have any 8 anymore). When I tried (from root) to `su sasl`, I got the reply "su: No shell" and was left at root.

Not quite what I was suggesting; I was thinking of logging in as a user that does have a valid shell and then "su"ing to root. AFAIK that simply changes the effective userid without changing the shell as opposed to su - root which simulates logging in as root, including changing to the shell configured for root in /etc/passwd.

choogendyk 04-10-2010 04:45 PM

Quote:

Originally Posted by catkin (Post 3931204)
Not quite what I was suggesting; I was thinking of logging in as a user that does have a valid shell and then "su"ing to root. AFAIK that simply changes the effective userid without changing the shell as opposed to su - root which simulates logging in as root, including changing to the shell configured for root in /etc/passwd.

But, `su sasl` is exactly what I tested. Not `su - sasl`.

So, just now I tested another one. I picked a user whose shell is bash. Mine is ksh. If I `su thatuser` (no "-"), I find that my shell is now bash. However, my environment otherwise (current directory, etc) is the same. If I had done `su - thatuser` I would have also gotten their login environment.

bathory 04-10-2010 05:36 PM

Hi,

su to root will not work with a bad shell for root. The procedure to recover from this situation is the one I've described in my port above.

Regards

mn35 04-12-2010 12:22 AM

Thanks all for sharing your ideas.

Bathory, is right. I'll go through the procedure. The only way to do it is from rebooting .. but i still didn't fix it yet.

(When i got to another login and su root [or - root or else ] it still gives me: No Shell . I even tried $ su root -c "vi /etc/passwd" but that didn't work as well)

I have a question, i have FTP running on this box and I have root in /etc/ftpusers being commented

$ cat /etc/ftpusers
# root
daemon
bin

but when i try to FTP in as root it tells me access denied (NB: there is no /etc/ftp/ the / is the ftp folder).

I wanted to use FTP to open /etc/passwd and change it, can you tell me why is it giving me access denied ?



thanks all.

bathory 04-12-2010 02:25 AM

Hi,

Same goes for ftp. Without a valid shell (even /bin/false) you cannot ftp into server.

Regards

choogendyk 04-12-2010 07:36 AM

Sorry if the side discussion confused things. It has always been my understanding that boot off cd, mount the root file system, edit /etc/passwd is the only solution. I should have made that clear when I chased the side discussion. Check the link bathory gave for recovery details.

mn35 04-13-2010 12:12 AM

Cheegendyk,
At first i also thought of a way which will ask for root credentials and utilize the 'others' shell .. but i couldn't think of anything, i thought about piping, forking, a script ..something .. i couldn't find a solution. Then -as mentioned above- i thought of FTP, i already had the FTP site open from a windows computer but with a different account, i tried FTP via root, but that also didn't work, i think the reason is that the root 'shell' verifies the login of the root; and launches FTP binaries or so - so that didn't work as well.

I have a bigger problem now, i dont have the Solaris 8 CD anymore, i have 9 and 10 .... lucky me.

I'll probably sleep for a couple of days and hope the problem would vanish .. by itself.

mn35 04-13-2010 12:19 AM

one last thing: if it was my own box and was able to shut it down for a short time, i would have physically pulled of the HardDisk, mounted it on windows system, took ownership of the /etc/passwd and modified it.

(I'll probably do that since i dont have the boot CD of solaris 8)

bathory 04-13-2010 02:01 AM

Can windows write on a UFS file system? Even linux support for writing on UFS is experimental
You best bet is to get an Opensolaris live-cd and boot from it.

Regards

jlliagre 04-13-2010 04:24 AM

Quote:

Originally Posted by mn35 (Post 3933631)
I have a bigger problem now, i dont have the Solaris 8 CD anymore, i have 9 and 10 .... lucky me.

That's not a problem. A Solaris 9 or 10 CD is bootable and can be used to mount a broken Solaris 8 filesystem in order to fix it.


All times are GMT -5. The time now is 11:42 AM.