Add a system user for Asterisk

For security reasons, it is recommended to run Asterisk as a separate system user, and not as root. That is why I’m going to create a new user using the useradd command. I will also configure the password for the user using the passwd command:

useradd asteriskuser
passwd asteriskuser
Changing password for user asteriskuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

We also need to provide the created user the ability to execute commands with root privileges using the sudo command. This is done by modifying the /etc/sudoers file. Two steps are involved. First, open the file for configuration using the visudo command. This command opens a file in a text editor and validates the syntax of the file upon saving:

visudo

Next, find the following lines (use the / character to initiate the search):

## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

Remove the # character at the beginning of the # %wheel line. Save and quit by pressing the Esc character and writing wq.

On CentOS, members of the wheel group have sudo privileges. Add the user you’ve created to the wheel group by executing the following command:

usermod -aG wheel asteriskuser

This will add asteriskuser to the wheel group. You can verify that the user was indeed added to the wheel group by executing the following command:

cat /etc/group | grep wheel
wheel:x:10:asteriskuser
Geek University 2022