Skip to content

Linux & Servers

Root User Management via SSH in Linux/Centos

 

1. Login as root (replace localhost with your server address)

Command
ssh root@localhost

To create a Root User Account

2. Type in this command and press enter (remember to replace <username>)

Command
useradd -ou 0 -g 0 <username>

3. Type in this command and press enter to create a password for the user

Command
passwd <username>

4. Type in the password for the user, press enter, and then reconfirm

5. If all goes well, a message should display

“Passwd: all authentication tokens updated succcessfully.”

To delete an existing Root User Account

2. Open /etc/passwd with something like nano editor by typing the command below and press enter

Command
nano /etc/passwd

3. Find the desired Root User Account in the file

Command
<username>:x:0:0::/home/<username>:/bin/sh

4. Change the UID to something else to disable root privileges, like:

Command
<username>:x:1111:0::/home/<username>:/bin/sh

4. Save the file and exit by pressing the “Ctrl” and “x”

5. Type in “Y” and press “enter” to confirm changes

6. You can now delete the User Account by typing in, followed by enter.

Command
userdel <username>

Leave a Reply

Your email address will not be published. Required fields are marked *