How to create a second root account with SSH access 11-29-2012, 03:38 PM
#1
I've implemented a method to log in as root even in server's that have root access disabled. Pro's: It's automatic (so to speak); Con's: It requires two passwords and a bit of funky code.
So, first step is to create your backup login and an appropriate root login. You can use root, however, considering the audience I have on this site, I'll assume you probably don't know the primary root's password and don't want to change it in order to avoid detection.
What you want to do is create two users. Do so as such.
Of course, replace nohbdy with whatever you please. Just make sure that you add both accounts and set the password.
After that, you need to edit the /etc/passwd file so that the alternate root user is UID=0 and GID=0. Look for the line that defines your new root user, and make the 500/1000 like numbers both 0's.
Make a file in the proxy user's directory (in my case /home/nohbdy) with the following code:
Make the file executable to the user you created, and edit the /etc/passwd to replace the /bin/sh or /bin/bash on the proxy users line to point to this file (ie, change the shell to /home/nohbdy/root.sh).
Log into the proxy user and test that it works. A common issue is that you pointed the su -l part to your proxy user as opposed to the root user.
There you have it. You have a root user that works even when ssh blocks root login.
So, first step is to create your backup login and an appropriate root login. You can use root, however, considering the audience I have on this site, I'll assume you probably don't know the primary root's password and don't want to change it in order to avoid detection.
What you want to do is create two users. Do so as such.
Code:
adduser nohbdy
adduser nohbdy_root
passwd nohbdy
passwd nohbdy_root
Of course, replace nohbdy with whatever you please. Just make sure that you add both accounts and set the password.
After that, you need to edit the /etc/passwd file so that the alternate root user is UID=0 and GID=0. Look for the line that defines your new root user, and make the 500/1000 like numbers both 0's.
Make a file in the proxy user's directory (in my case /home/nohbdy) with the following code:
Code:
#!/bin/sh
su -l nohbdy_root
Make the file executable to the user you created, and edit the /etc/passwd to replace the /bin/sh or /bin/bash on the proxy users line to point to this file (ie, change the shell to /home/nohbdy/root.sh).
Log into the proxy user and test that it works. A common issue is that you pointed the su -l part to your proxy user as opposed to the root user.
There you have it. You have a root user that works even when ssh blocks root login.
FART BUBBLES!