Create New User
For security reason, it is safe to use a shadow user
which sudo powers instead of the root account.
To improve security, you can create a user that will not be easy for other people to guess. In this guide, we will use the huser14
.
Create the user:
sudo useradd -d /home/huser14 -s /bin/bash -m huser14
Give the user sudo access:
sudo usermod -a -G sudo huser14
Set a password:
sudo passwd huser14Make sure your password is at least 8 characters long containing a complex combination of numbers, letters, and punctuation marks.
Remove Password Prompt For sudo
If it possible to remove password prompt when using the sudo command.
To remove password prompt for sudo during the hardening process, edit the sudoers file:
vi /etc/sudoers
and add or replace the line:
huser14 ALL=(ALL) NOPASSWD: ALL
Revert the changes
It is recommended to revert the "Remove Password Prompt" to its original state. If you disable the sudo password, you will compromise the security of your server.
sudo vi /etc/sudoers
and replace the line:
huser14 ALL=(ALL) NOPASSWD: ALL
to
huser14 ALL=(ALL:ALL) ALL
Try it out!
Now, let's try to log with your new account.
I recommend NOT to close your current connection, instead open a new shell or putty and try it!