03. Secure the Pi a Little
We're going to create a new user, give that user sudo privileges and then disable the root user so people are less likely to play hackerman with us
Add a new user:
sudo adduser <new-username>
After entering a password you can just hit
Enter
to skip all the other questions and then save the new user.Grant admin privileges to your new user:
sudo usermod -aG sudo <new-username>
Logout of this ubuntu user and login with your new username:
logout
Delete the old ubuntu user:
sudo userdel -r ubuntu
Make sure it deleted by logging out and trying to login with
ubuntu
All good? Now let's do something about that pesky root user...
Lets change/remove the shell from the root account:
sudo usermod -s /usr/sbin/nologin root
Disable root from logging in:
sudo usermod -L root
This will basically reset the password for root and they will not be able to login until we assign them a new password.
While we're doing all this housecleaning, let's set up a firewall...
Firewall
We're going to use ufw as a firewall to block all incoming connections
Install Uncomplicated Firewall (ufw)
sudo apt-get install ufw
Check that it installed correctly:
sudo ufw status
You should see "Status: Inactive"Disable all incoming connections:
sudo ufw default deny incoming
Enable ufw:
sudo ufw enable
Note: If you are applying new rules to ufw while it is active you will have to reload (sudo ufw reload
) the firewall for the changes to take effect.
Last updated