How to Create Sudo User and Disable Root Access
Create Sudo User
Create a new user by running the adduser command.
sudo adduser username
Replace "username" with the desired username. You’ll be prompted to set a password and provide some basic information.
After creating the user, you need to add them to the sudo group to allow them to execute commands with root privileges.
sudo usermod -aG sudo username
Switch to the newly created user and test if they have sudo access by running following command.
su - username
sudo ls /root
You’ll be prompted for the user’s password. If they can successfully run the command with sudo, the setup is complete.
Disable Root Access
Open the /etc/ssh/sshd_config
SSH Configuration File,
nano /etc/ssh/sshd_config
To disable root access and password authentication, Open the SSH configuration file,
nano /etc/ssh/sshd_config
Look for the line containing PasswordAuthentication. If it’s commented out (with a #), uncomment it by removing the #
and Set the value to no
like this.
PasswordAuthentication no
To disable root login, find the line PermitRootLogin
and set it to no
:
PermitRootLogin no
Then save the file and exi. Next Restart the SSH service,
systemctl restart sshd
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS