When setting up an Ubuntu server, it’s essential to create a separate user with sudo privileges to execute administrative commands securely. This guide will walk you through the process step by step.
Step 1: Log in as Root
Before creating a new sudo user, ensure you are logged into your Ubuntu server as the root user or an existing sudo user.
ssh root@your_server_ip
Step 2: Create a New User
Use the adduser command to create a new user. Replace username with your preferred name.
adduser username
You will be prompted to set a password and provide optional user details.
Step 3: Grant Sudo Privileges
Once the user is created, add them to the sudo group to grant administrative privileges:
usermod -aG sudo username
Step 4: Verify Sudo Access
Switch to the new user account:
su - username
To check if the user has sudo privileges, run:
sudo whoami
If configured correctly, the output should be root.
Step 5: Secure Your Server
For enhanced security, disable root login via SSH. Open the SSH configuration file:
nano /etc/ssh/sshd_config
Find the line:
PermitRootLogin yes
Change it to:
PermitRootLogin no
Save the file and restart SSH:
systemctl restart ssh
Conclusion
Creating a sudo user on an Ubuntu server enhances security by preventing direct root access. By following these steps, you can manage administrative tasks safely and efficiently.
How to Create a Sudo User in Ubuntu Server (F.A.Q)
Why should I create a sudo user instead of using root?
Using a sudo user minimizes security risks, as it prevents accidental system-wide changes and reduces vulnerability to attacks.
How to Check Shutdown Logs in Event Viewer on Windows Server 2022 Monitoring server shutdowns is critical for administrators to...
Black Friday Mega Sale Week – Massive Deals Live Now!
Check Offer
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.