Create a New User Account and Disable Root Account on Linux VPS
☰ In this chapter, you will learn
- How to Create a new user account on Linux?
- How to add user account in sudo group?
- How to disable root account?
When securing a Linux web server, it's essential to take a few key steps. First, create a new user account. Then, give that user access to sudo. Finally, disable the root account.
The root user, also called the superuser, has full control over the system. They can do anything, like change important files or install software.
A sudo user is like a deputy root. They have some of the same powers but need to confirm their identity with a password.
To keep a web server safe, it's smart to turn off the root user. Instead, make a new user with sudo access. That way, you still have control, but it's safer.
Here's the detailed tutorial on how to create a new user and add them to sudo group.
How to create a user and add them to the sudo group
Disabling Root account
sudo vi /etc/ssh/sshd_config
- Press
i
to enter intoinsert
mode. - Then set the PermitRootLogin value to no.
- Press Esc, then type :wq and press Enter to Save and Exit.
sudo vi /etc/ssh/sshd_config
# Logging #SyslogFacility AUTH SyslogFacility AUTHPRIV #LogLevel INFO # Authentication: #LoginGraceTime 2m PermitRootLogin no #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #PubkeyAuthentication yes -- INSERT --
Ubuntu
service ssh restart
CentOS
systemctl restart sshd
Once you've disabled the root user and made a new account with sudo access, you're good to go. You can now run commands and manage files and settings on your VPS server.