Create SUDO user in cPanel

For security you might want to disable direct SSH login as root.

First of all login as root and create an user which

useradd sshadmin
passwd sshadmin

Now add this user to wheel group from WHM

WHM -> Security Center -> Manage Wheel Group Users

OR from command line

usermod -G wheel sshadmin

Now open /etc/ssh/sshd_config and set

PermitRootLogin no

Restart the ssh service

/etc/init.d/sshd restart

Now you can ssh to server as user sshadmin and run the command “su -” to switch to root user.

Now the thing is that “su -” asks for root password. If you don’t want to remember the root password then you can add the user sshadmin to sudo user list. Add below lines to /etc/sudoers

sshadmin    ALL=(ALL)       ALL

Now run the command “sudo su -” and it will directly switch to user root without asking password.

Show 2 Comments


  1. Luis

    Hi, thanks for this tip, you save me a lot of time!!

Comments are closed