How to Secure a Raspberry Pi

Ryan Jonker Cybersecurity
3 min readApr 28, 2021
A Raspberry Pi can be a fun and powerful tool! (Photo credit: Harrison Broadbent)

A Raspberry Pi is a tiny, inexpensive computer. It is a great tool for everyday computing tasks, learning how to code, and even retro gaming. As hardware like this becomes more popular and inexpensive, it is that much more important to understand how to secure these devices from attackers. To secure your device, check out the following steps!

Change the Default Password

Change the default password on all of your devices! (Photo credit: Amazee Labs)

One of the first steps you should take to secure your Raspberry Pi is to change the default password. These settings can be changed from the “raspi-config” application, or by typing “sudo raspi-config” from the command line. An even faster way to change this password would be to just type “passwd” into the command line, which will then prompt you to type in a new password.

This is an incredibly important step you should take on any new device, including routers, computers, smart devices, and anything else with an internet connection. To leave the default password unchanged is to invite attackers into your system freely.

Set Up a New User Account

Avoid using the default username when possible (Photo credit: Aryan Dhiman)

Everyone that knows about the Raspberry Pi knows that the default username is “pi.” That in itself is a good reason to use a different username. To add a new user named “ryan,” simply type “sudo adduser ryan” in the command line. You can then go through the process of deleting the “pi” user, but it is important to note that some applications require the “pi” user to be present. If you have determined that you are ready to delete the “pi” user, you can read more about that topic in the official documentation here; just make sure you save any data from the “pi” user directory that you might need later!

Require a Password for “Sudo”

The “sudo” command stands for “superuser do.” (Photo credit: Joan Gamell)

The “sudo” command is what allows Raspberry Pi users to act as a “superuser,” giving them elevated privileges with the ability to modify important system files. Unfortunately, the sudo command does not require a password by default, leaving your device vulnerable to attackers!

To force “sudo” to require a password, type “sudo visudo /etc/sudoers.d/010_pi-nopasswd” and change the “pi” entry (or whichever usernames have superuser rights) to: “pi ALL=(ALL) PASSWD: ALL” and save the file. For more details, check out the documentation.

Download the Latest Updates

Keep your system updated to stay secure! (Photo credit: Vishnu Mohanan)

Keeping your Raspberry Pi updated is a fast and easy way to increase security. As vulnerabilities are discovered in software, developers release updates to protect against those weaknesses.

To update your Raspberry Pi, simply type “sudo apt update” in the command line and press enter. This updates your system’s package list. Then, type “sudo apt full-upgrade” which upgrades your software to the latest version. That’s it!

For more details, read the manual here regarding system updates. For more ways to secure your Raspberry Pi, check out the official documentation here.

Thanks for reading! Check out this article and more like it on my website!

https://youtu.be/bod_Z9UYWGU

--

--