![]() The whoami command will return root when coupled with sudo.Systemctl restart rvice Step 7: TestingĪfter you have restarted the SSH server, log out and then log back in as your sudo user, then attempt to execute some testing commands as follows:Īny of the below commands will allow the sudo user to become root. In order to apply the changes you made to /etc/sudoers, you need to restart the SSHD server as follows: Debian It is possible to allow a user that is in neither user groups to execute the sudo command by simply adding them to /etc/sudoers as follows:Īnotherusername ALL=(ALL) ALL Step 6: Restarting the SSHD Server Step 5: Allowing a user that belongs to neither the wheel nor the sudo group to execute the sudo command If the line starting with %sudo in Debian or %wheel in RHEL/CentOS is not commented out (prefixed by #), this means that sudo is already setup and is enabled. ![]() In some systems, you may not find %wheel instead of %sudo in which case, this would be the line under which you would start modifying. This section of /etc/sudoers often looks like this: # Allow members of group sudo to execute any command Start reviewing and editing below this line: Note: The visudo command will open /etc/sudoers using the system's preferred text editor (usually vi or vim). In order to accomplish that, we will view the contents of /etc/sudoers and edit them where applicable. It is important to ensure that sudoers file located in /etc/sudoers is setup properly in order to allow sudo users to effectively use the sudo command. Usermod -aG wheel mynewusername Step 4: Making sure your sudoers file is setup properly Usermod -aG sudo mynewusername RHEL/CentOS Essentially, there is no real difference except for the syntax used to become root, and users belonging to both groups can use the sudo command. Meanwhile, a sudo user would have use the sudo su first. ![]() In CentOS and Debian, a user belonging to the wheel group can execute su and directly ascend to root. For the purpose of this tutorial, we will use the sudo group for Debian. You can however manually add the wheel group using the groupadd command. Note: In Debian, the sudo group is often found instead of wheel. Adding your sudo user to the wheel group is entirely optional, but it is advisable. The wheel group is a user group which limits the number of people who are able to su to root. RHEL/CentOS and DebianĪdduser mynewusername Step 3: Adding the new user to the wheel group (optional) Yum install sudo -y Step 2: Adding the sudo userĪ sudo user is a normal user account on a Linux or Unix machine. In this tutorial, we will be covering the basic steps for disabling direct root access, creating a sudo user, and setting up the sudo group on RHEL/CentOS and Debian Linux systems. ![]() The use of a sudo user is often coupled by disabling direct root access to one's server in an effort to prevent unauthorized access. Using a sudo user to access a server and execute commands at root level is a very common practice among Linux Systems Administrators. How To Install and Configure Sudo on RHEL/CentOS and Debian ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |