To ensure your system is up to date, run the following commands:
sudo apt update && sudo apt upgrade -y
This will update the package list and upgrade all installed packages.
Creating a new sudo user helps maintain security instead of using the root account.
Replace username
with your desired username:
sudo adduser username
You will be prompted to enter a password and user details.
sudo usermod -aG sudo username
This adds the user to the sudo
group, allowing administrative access.
Switch to the new user:
su - username
Run a test command:
sudo whoami
If successful, it should return root
.
To enhance security, disable SSH access for the root user.
sudo nano /etc/ssh/sshd_config
Change:
PermitRootLogin yes
To:
PermitRootLogin no
Press CTRL+X
, then Y
, and hit ENTER
to save the file.
sudo systemctl restart ssh
Try logging in as root via SSH:
ssh root@your-server-ip
It should now be blocked.
ufw
to allow only necessary connections.Your Ubuntu system is now updated, secure, and configured with a sudo user.