I just took over a server from someone. As a "security measure" they have made it impossible to login to the machine (or su) as root, by setting the root user to /sbin/nologin in /etc/passwd. Unfortunately, none of the other user accounts have full root access, and it has now become necessary to change certain configurations which require root access. Is there a way to easily restore (or edit) /etc/passwd to re-enable root access to the machine?
I was thinking about simply unplugging the drive, plug it into a different machine I have, and then edit the file from there. Is there a different/better/easier way of doing this?
I believe that if you can edit the password file, and remove the password hash, you can login as root without a password. But I think the flaw in my plan is that you won't be able to edit the password file unless you login as root.
Failing that, you're suggestion (mount drive somewhere where you have root) and then editing the password file to remove the hash is the best/only way to go.
A couple of ideas off the cuff: as you've got physical access, you can try rebooting the machine and at the lilo prompt you can type linux single to boot the machine into single-user mode. That might give you root access (without a password) and would allow you to edit /etc/passwd. If you don't know the root password, you can also reset it with passwd. Otherwise, can you boot the machine with a live CD?
If you want to remove the hash for the root password, I think you'll have to edit
I would recommend quickly parsing through /etc/passwd to see if there are any other users that have uid 0. It wouldn't make sense to lock out the root user without replacing it with another user, as it basically means that you can never perform system-level configuration.
If another user has uid 0, then they have root access.
You said that none of the other users has "full" root access. Depending on what type of access they do have (for example, can any of them use sudo? su?, run a program as root another way?), you may still be able to use them to edit the passwd file.
It might also be helpful to mention what OS you are running. For example, on a FreeBSD install with security turned on, you wouldn't be able to boot into single-user without knowing the password.