Join our Newsletter — 33% off our NHI Course
Home› Guides› Raspberry Pi for Beginners: Securing a Pi Before…
Guide Endpoint Security

Raspberry Pi for Beginners: Securing a Pi Before You Put It Online

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 3 December 2026 12 min read
On this page

A Raspberry Pi is a small, low-cost computer that needs the same security care as any other computer.

This guide is for anyone setting up a Pi at home, in a classroom club or in a small office. You do not need to be an expert. If your Pi will run a home server, a camera or a smart home hub, these steps apply before it goes online.

In short

  • A Pi runs a full operating system, so it can be broken into like a laptop or a server.
  • Create your own username and a long password, and keep the system updated.
  • Turn on remote access (SSH) only if you need it, and use keys rather than passwords where you can.
  • Avoid opening router ports to the Pi. Use a private route in, such as a remote access service or a home VPN.

What you will learn

  • Explain why a tiny computer still needs proper security.
  • Check the account, update and remote access settings on your Pi.
  • Spot the risk in forwarding a router port to your Pi.
  • Choose a safer way to reach your Pi from outside your home.
Remote control by text (SSH)
a secure way to type commands on a computer from another device.
Opening a door in your router (port forwarding)
a router rule that sends traffic from the internet to one device at home.
Traffic filter (firewall)
software that lets in only the connections you allow.

What is Raspberry Pi security?

Think of building a garden shed yourself. Nobody fits the lock for you. You choose the lock, and you decide whether to add a door that opens onto the street.

A Raspberry Pi is the same. It is a small, cheap computer, often used for hobby projects and home servers. Its usual system, Raspberry Pi OS, is a version of Linux. Securing it means setting up who can sign in, keeping it updated, and controlling who can reach it over the network.

Many people treat a Pi like a gadget. But once it is on your network, it is a real computer. If it is badly set up, it can become a way into your other devices.

Where the comparison stops working: a shed is only reachable by people on your street. A Pi connected to the internet can be reached by anyone in the world, unless you keep its doors shut.

Why does it matter?

A Pi often runs all day, every day, and is easy to forget. That makes it worth a little care at the start.

If you tinker at home

What could happen: a Pi with an easy password and an open router port is found and taken over by a stranger.

Check this: look in your router settings for any rule that forwards a port to your Pi.

Next: Home Router Security for Beginners

If you run a school or club project

What could happen: several Pis share one password, so anyone who learns it can sign in to all of them.

Check this: give each person their own account, and remove accounts that are no longer used.

Next: Linux Security for Beginners

If you use a Pi in a small business

What could happen: a Pi running a sign or sensor sits on the office network, unpatched for years.

Check this: add every Pi to your list of devices, with an owner who keeps it updated.

Next: IoT Security for Beginners

What does it look like?

Here is a made-up set-up card for a home Pi. The numbered lines show common gaps.

Example only. All values are made up.

Device:      EXAMPLE-pi-0000 (home media server)
User:        admin / password: FAKE-1234            (1)
Last update: 18 months ago                          (2)
SSH:         on, password sign-in allowed           (3)
Firewall:    off                                    (4)
Router rule: port 22 forwarded to EXAMPLE-pi-0000   (5)
  1. In a real file, this line would show the account name. A common name with a short password is easy to guess.
  2. Old software may have known flaws that updates have fixed.
  3. SSH with passwords lets anyone who reaches it keep guessing.
  4. No filter means every service on the Pi can be reached.
  5. This rule puts the Pi's remote control door on the open internet.

Why this is risky: together, these let a stranger find the Pi, guess the password and take control.

The safer way: a personal account with a long password, regular updates, SSH with keys or off, a firewall, and no forwarded ports.

How does it work?

The official Raspberry Pi documentation sets out a few core habits. Here they are in plain words.

  1. Create your own account. Older versions of Raspberry Pi OS came with a default user called "pi". Since April 2022, you create your own user at first start, or ahead of time in the Raspberry Pi Imager tool [1]. The project said a well-known username could make password guessing slightly easier [1].
  2. Keep passwords switched on. The documentation advises requiring a password at start-up and for admin commands, called sudo (a way to run a single command with admin rights) [2].
  3. Update often. Keep the software up to date, and move to the latest major release, which is the one that gets all security fixes [2].
  4. Use SSH with care. Raspberry Pi OS turns the SSH server off by default [3]. If you turn it on, the documentation recommends key-based sign-in (a matched pair of digital keys instead of a typed password) [2]. Imager can add your public key for you [3].
  5. Add a firewall and a guard. The documentation suggests a simple firewall called UFW, and a tool called Fail2Ban that watches for repeated failed sign-ins [2].
Diagram titled Setting up a Pi safely: five steps. Five boxes in a row joined by arrows. 1, Your account: pick your own username and a long password. 2, Update: install updates now, then keep doing it. 3, Careful SSH: turn it on only if needed, and use keys if you can. 4, Firewall: allow only the services you really use. 5, Stay inside: reach it remotely without opening router ports. A note underneath says do steps 1 to 4 before the Pi is reachable from outside your home network.
Figure 1. Five set-up steps, in order, before a Pi faces the internet.

The last step is about reaching the Pi from outside. Port forwarding tells your router to send outside traffic to the Pi. That puts the Pi in front of the whole internet. A feature called UPnP lets devices change router settings such as port forwarding by themselves. Canada's national cyber centre advises turning UPnP off on home routers, or reviewing port forwarding rules regularly if it stays on [5]. The US National Security Agency also advises turning UPnP off on home routers [7].

There are other routes in. Raspberry Pi Connect, the maker's own remote access service, lets you reach a Pi through a web browser. It usually works without changes to your network or firewall, and its sessions are encrypted [4]. A VPN to your home network is another option.

Diagram titled Reaching your Pi from outside: two ways. Left panel, Riskier: open a router port. The router forwards a port to the Pi; anyone online can try to connect; password guessing can start; a missed update is open to all; this needs the Pi to be fully hardened. Right panel, Safer: a private route in. No open ports on the router; a remote access tool or home VPN; you sign in to the service first; only your devices can reach the Pi; still keep the Pi updated.
Figure 2. An open router port compared with a private route in.

A worked example

Rhys Morgan, a retired teacher, sets up a Pi as a home photo server. A forum post tells him to forward a port on his router so he can see his photos while travelling. He does it, and it works.

A month later his grandson visits and looks at the Pi. The account is called "admin" and the password is the name of Rhys's dog. SSH is on, with password sign-in. The system has not been updated since the day it was set up.

They check the sign-in records on the Pi. They see many failed attempts from addresses they do not recognise. There are no successful sign-ins in the records they can find, but they decide not to take chances.

First, they remove the port forwarding rule on the router and turn off UPnP. Then they back up the photos to a separate drive. Next, they install a fresh copy of Raspberry Pi OS using Imager. This time they create a new username and a long passphrase, and add Rhys's public key for SSH.

After setting it up, they install all updates, turn on the UFW firewall and set up Fail2Ban. For travel, they set up Raspberry Pi Connect, so the router needs no open ports.

Rhys writes a note on the box: "Update on the first Sunday of each month." He adds a reminder to his phone.

The lesson: the forum tip worked, but it opened a door for everyone. A private route in gave him the same access with far less exposure.

Myths and mistakes

What people thinkWhat is true
Nobody would bother attacking a tiny hobby computer.Devices reachable from the internet can be scanned and probed, whatever they are [7].
Linux on a Pi does not need updates.The documentation advises keeping software current and using the latest major release.
Port forwarding is the normal way to reach a Pi from outside.It works, but it exposes the Pi to everyone. A remote access service or VPN avoids open ports.
A firewall on the Pi means I can relax.A firewall helps, but accounts, updates and SSH settings still matter.
Raspberry Robin malware attacks Raspberry Pis.Despite the name, it is a worm that spread to Windows computers through infected USB drives [6].

What can I do this week?

  • Sign in to your Pi and check the account names. Remove any you do not use.
  • Install all updates, and set a monthly reminder to repeat it.
  • Check whether SSH is on. Turn it off if you do not need it, or switch to key-based sign-in.
  • Open your router settings and remove any port forwarding rule for the Pi. Turn off UPnP if you do not need it.
  • Turn on a firewall that allows only the services you use.

Checklist

  • My Pi uses my own username, not a common one.
  • The password is long and not used anywhere else.
  • A password is needed at start-up and for admin commands.
  • The system is updated, and I have a reminder to keep it that way.
  • SSH is off, or uses keys rather than passwords.
  • A firewall allows only the services I need.
  • No router port is forwarded to the Pi, and UPnP is off unless needed.
  • I have a backup of anything important stored on the Pi.

Common questions

Is my old Pi still using the "pi" user?

It may be. Systems set up before April 2022 came with a default "pi" user [1]. Check the accounts on your Pi. If "pi" is still there, create your own account, check it works, and then remove or lock the old one.

Do I need SSH at all?

Only if you want to type commands from another device. If your Pi has its own screen and keyboard, you may not need it. SSH is off by default on Raspberry Pi OS [3], so leave it off unless you have a reason.

How can I reach my Pi when I am away from home?

Use a route that does not open your router to the world. Raspberry Pi Connect gives browser access and usually needs no network changes [4]. A VPN to your home network is another choice. Keep the Pi updated either way.

What if I think my Pi has been broken into?

Unplug it from the network first. Copy off any personal files you need, then reinstall the system from scratch with new passwords. Change any passwords that were stored on the Pi, and remove any router rules pointing at it.

Is Raspberry Robin a Raspberry Pi threat?

No. Raspberry Robin is the name researchers gave to a worm that spread to Windows computers through infected USB drives [6]. The name is a coincidence. Read the Raspberry Robin Malware Guide for more.

Where next?

Ready for the detail? Read the practitioner guide: Linux Server Hardening Guide. It goes further into account rules, SSH settings, firewall policies and checking a system against a security baseline.

Also useful:

Related NHI Mgmt Group resources: IoT Security for Beginners, Linux Permissions for Beginners and Smart Home Security for Beginners.

Key terms

Raspberry Pi
A small single-board computer used for hobby projects, home servers and simple devices.
SSH
An encrypted way to type commands on another computer over a network.
SSH key
A matched pair of digital keys used to sign in over SSH instead of a password.
Firewall
A filter that blocks network connections you have not allowed.
Port forwarding
A router rule that sends traffic arriving from the internet to one device on your network.
UPnP
A feature that lets devices find each other and change router settings, such as port forwarding, by themselves.
Fail2Ban
A tool that watches for repeated failed sign-ins and blocks the source.
VPN
An encrypted tunnel that links your device to a private network, such as your home network.

Sources and further reading

  1. Raspberry Pi, "An update to Raspberry Pi OS Bullseye", Raspberry Pi News, 7 April 2022. https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/ (accessed 2 Dec 2026).
  2. Raspberry Pi Documentation, "Operational security". https://www.raspberrypi.com/documentation/security/operational-security.html (accessed 2 Dec 2026).
  3. Raspberry Pi Documentation, "Remote access". https://www.raspberrypi.com/documentation/computers/remote-access.html (accessed 2 Dec 2026).
  4. Raspberry Pi Documentation, "Raspberry Pi Connect". https://www.raspberrypi.com/documentation/services/connect.html (accessed 2 Dec 2026).
  5. Canadian Centre for Cyber Security, "Universal plug and play (ITSAP.00.008)", September 2025. https://cyber.gc.ca/en/guidance/universal-plug-play-itsap00008 (accessed 2 Dec 2026).
  6. Microsoft Threat Intelligence, "Raspberry Robin worm part of larger ecosystem facilitating pre-ransomware activity", 27 October 2022. https://www.microsoft.com/en-us/security/blog/2022/10/27/raspberry-robin-worm-part-of-larger-ecosystem-facilitating-pre-ransomware-activity/ (accessed 2 Dec 2026).
  7. US National Security Agency, "Best Practices for Securing Your Home Network", Cybersecurity Information Sheet, February 2023. https://media.defense.gov/2023/Feb/22/2003165170/-1/-1/0/CSI_BEST_PRACTICS_FOR_SECURING_YOUR_HOME_NETWORK.PDF (accessed 2 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.