No Superuser, I screwed up again.

I screwed up big time and again I come on my knees begging for help.
I have a remote machine. I added rbash via ports in an attempt to restrict a user to his home directory.
Now when I try to login as superuser:
# SU
I get:
Code:
su: /bin/rbash: No such file or directory

rbash is in /usr/local/bin

There is a symbolic link in /usr/local/bin: rbash -> bash

I actually don't know what is really wrong. Is there any hope? I am a 68 year old FreeBSD hobbyist with a small commercial website I made myself. I have worked on building this server for six weeks now and this has just about got me in tears. I know it's all my fault but you try to learn and you make mistakes. Any assistance so I can access superuser would be appreciated more than you will ever know.

This is my path:
Code:
set path = (/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games $HOME/bin)
Code:
uname -a
FreeBSD drabel.com 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May  1 08:49:13 UTC 2009     root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
 
Log in as normal user then pretend to edit a new file
Code:
$ vi new.txt
Now from withing vi start a normal unrestricted shell
Code:
:!/bin/sh
or
Code:
:!sh

You now should have a normal unrestricted shell. When you have fixed things type exit to return to vi
 
The problem that's happening is that when you log in, the computer starts the shell specified in /etc/passwd for you to interact with the system. When you set the shell for root to /bin/rbash when it was really located in /usr/local/bin/rbash and try to log in, it tries to execute the /bin/rbash file - since it doesn't exist, it cannot do so and dies.

Try logging in as 'toor' - it's a backup for root.

If you can edit the /etc/passwd file, you can manually change the shell back to something that exists.

You could also try creating a symlink to /usr/local/bin/rbash into /bin, though I don't know how'd you do this if you don't have root access. [cmd=]ln -s /usr/local/bin/rbash /bin/rbash[/cmd] should do it once you have access.



Advice for the future - when changing something that might have an effect logging in, log in as root on a window and don't log out until you know by testing in other windows that it works. (Not that I've ever done something similar.... ;) :) )
 
You might be able to get superuser mode again with [CMD="su"] -m[/CMD]. Then you can fix the superuser shell with [CMD="vipw"] command[/CMD]

Its generally not a good idea to have any shell but /bin/csh or /bin/sh for the root (superuser) user. If things get mucked up, you want the root shell to have the maximum chance of working. Instead, create a standard user and log in and/or su to that login.
 
Wow! Four replies in five minutes. You people are great! Thank you! Thank You!

I'll start with #1 and reply with results shortly.
 
Ruler2112
Thank you for the very good advise. I will remember that.
Regretfully I did not have webmin installed on this server yet.
I tried toor and:
toor: Command not found.
 
Christopher:

This worked!!!!!

"You might be able to get superuser mode again with su -m. Then you can fix the superuser shell with vipw command"

Thank you!!!

At first I didn't realize I was in su mode. Luckily I did
# whoami
# root

and I was then able to edit the file. Now I can login normally.

How can I get your PayPal address so I can buy you a beer?
 
adriftinitland said:
J65nko: I can get into a new shell but when I do
# su:
I get: /bin/rbash: No such file or directory

Try
Code:
su - root

Or alternative try to start a csh from within vi.
 
adriftinitland said:
Ruler2112
Thank you for the very good advise. I will remember that.
Regretfully I did not have webmin installed on this server yet.
I tried toor and:
toor: Command not found.

What you're looking for is % su toor, but it looks like you fixed it.
 
fronclynne said:
What you're looking for is % su toor, but it looks like you fixed it.

Yeah, what he said. toor is a backup for root (backwards) - you log in as toor and you have root access.

Glad you got it fixed. :)
 
The 'toor' account isn't enabled by default (it has no password or shell set). Someone would have to deliberately enable it with 'passwd toor' and set a shell before it would work.

For my part, I enable the toor account and set its shell to /bin/sh and leave it as my failsafe root account, then I change my main root account shell to my preferred shell from ports (bash usually).
 
jem said:
The 'toor' account isn't enabled by default (it has no password or shell set). Someone would have to deliberately enable it with 'passwd toor' and set a shell before it would work.

For my part, I enable the toor account and set its shell to /bin/sh and leave it as my failsafe root account, then I change my main root account shell to my preferred shell from ports (bash usually).

Can't you just boot the machine in single user mode, use the recovery shell and fix stuff from there ?
 
Artefact2 said:
Can't you just boot the machine in single user mode, use the recovery shell and fix stuff from there ?

The OP didn't have access to the box.

I guess I wasn't aware that toor was not enabled by default; it must be one of those things I do and hardly think about when installing a system...
 
Back
Top