Raspberry Pi OS ships with SSH disabled by default. This is a deliberate security decision (a default-on SSH service with the well-known pi username was a known weak point on early Pi models). Enabling it is straightforward, but the right method depends on whether you have a monitor and keyboard attached, and which Pi OS version you’re on.
This guide covers the three methods Raspberry Pi’s own documentation describes, on current Raspberry Pi OS (a Debian Trixie base since October 2025).
Short answer: with a monitor and keyboard, run sudo raspi-config and choose 3 Interface Options then I1 SSH. For a headless Pi, turn on Enable SSH in Raspberry Pi Imager’s Customisation tab before you write the card, or put an empty file named ssh and a userconf.txt (your username and an encrypted password) on the bootfs partition.
Checked on: 15 November 2026. The
raspi-configscreens and the SSH status checks were captured on a real Raspberry Pi 4 Model B (Rev 1.4) running Raspberry Pi OS Trixie. SSH was already enabled on that Pi, so we only looked at the screens and ran read-only checks; we did not switch anything on or off. The Imager steps were run in Raspberry Pi Imager 2.0.12 on an x86 test machine in the ReadTheManual lab (every screen up to Remote access, nothing written to a card). The first-boot route (thesshanduserconf.txtfiles onbootfs) and the Control Centre switch follow Raspberry Pi’s getting started and configuration documentation and were not run on hardware. The login screenshot is a local demo against a throwaway test server on a side port, not the Pi’s own SSH service. The error messages in the errors section were reproduced on an Ubuntu test VM.

Method 1: raspi-config (when you have a monitor + keyboard)
The official tool for changing Pi configuration.
sudo raspi-config
Navigate using arrow keys:
- 3 Interface Options -> Enter
- I1 SSH -> Enter
- Yes to “Would you like the SSH server to be enabled?”
- OK
- Finish to exit


SSH is now running and starts automatically on every boot. This is the menu path in Raspberry Pi’s raspi-config documentation. On the desktop, the same switch is under Preferences > Control Centre, on the Interfaces tab.
Verify:
sudo systemctl status ssh
You want Active: active (running).
To check the setting without opening the menu, sudo raspi-config nonint get_ssh prints 0 when SSH is enabled and 1 when it is disabled.


Method 2: Headless setup via the boot partition (no monitor needed)
For a Pi that will run headless, when you did not use Imager’s Customisation tab. Raspberry Pi OS has had no default user since 2022, so SSH needs two files on the card, not one: an empty ssh file to turn the server on, and a userconf.txt file to create the account you will log in as. Raspberry Pi’s getting started documentation lists both under its manual setup for SSH.
After you have flashed Raspberry Pi OS to the card, and before you eject it:
- Open the
bootfspartition. It should mount on its own and appear as a drive in your file manager. In a terminal that iscd /Volumes/bootfson macOS orcd /run/media/$USER/bootfson most Linux desktops. - Create an empty file named
sshwith no extension. On Linux or macOS:touch ssh. On Windows, create a text document in the partition, name itsshand remove the.txt(turn on file extensions in Explorer if you cannot see it). - Make the encrypted password. In a terminal on your computer run
openssl passwd -6, type your password when prompted and confirm it. It prints a long string starting$6$. (The default macOSopensslis LibreSSL and does not support-6; the Raspberry Pi docs suggest installing OpenSSL with Homebrew.) - Create a file named
userconf.txtin the same partition containing one line:username:encrypted-password, for examplealex:$6$...with the string from step 3. The docs say the username must start with a letter and use only lowercase letters, digits, underscores and hyphens, up to 31 characters. - Eject the card cleanly, put it in the Pi and power on. Allow a few minutes on first boot.
cd /run/media/$USER/bootfs
touch ssh
echo "alex:$(openssl passwd -6)" > userconf.txt
The last command asks for the password twice and writes the line for you. Do not put a plain-text password in userconf.txt; it has to be the encrypted string.
On a Pi that is already running, sudo touch /boot/firmware/ssh followed by sudo reboot does the same job for SSH (remote access documentation), but the account has to exist already.
Method 3: Raspberry Pi Imager pre-config (recommended for new builds)
Raspberry Pi Imager lets you set SSH, the user and the network before the card is written. The current release is v2.0.12, and the screenshots below are from it, run on an x86 test machine in the ReadTheManual lab with nothing written to a card. They follow the Customise your operating system section of Raspberry Pi’s documentation. This is now the easiest path.
- Open Raspberry Pi Imager and choose your device.
- Choose the OS. Raspberry Pi OS (64-bit) is the recommended entry and is a port of Debian Trixie.
- Choose your storage device. If the OS can be customised, the Customisation steps follow. (You can use Skip customisation, but then SSH stays off.)
- Work through the subtabs with Next: Hostname (letters, numbers and hyphens only, for example
pi5-server); Localisation (pick your capital city and Imager fills in the time zone and keyboard layout; Next stays greyed out until you do); User (a username and password, since there is no default user); Wi-Fi (a secure or open network, if going wireless); Remote access; and Raspberry Pi Connect. - On Remote access, switch Enable SSH on, then choose Use password authentication or Use public key authentication. The key option adds a keys section with a Show button for your public key.
- Continue to Writing to write the card.





When the Pi boots for the first time, it already has SSH enabled, the network configured, and (optionally) your SSH key in ~/.ssh/authorized_keys. You can SSH in straight away.
This eliminates the entire “find the IP, ssh in, run raspi-config” loop. Recommended for anyone setting up multiple Pis.
Default username gotcha
Older Pi OS images shipped with a default user pi and password raspberry. This is no longer the case.
Pi OS Bullseye (April 2022) and later require you to set a username and password during first boot, in Imager’s Customisation step, or in a userconf.txt file on the card (Method 2). There is no pi user unless you explicitly create one.

If a tutorial says ssh [email protected] and the login fails with Permission denied, that’s why. Use the username you set during install (or via Imager).
To find your hostname if you forgot:
hostname # run on the Pi to see what it's set to
By default, Pi OS uses raspberrypi.local (mDNS) but if you set a custom hostname in Imager, use that instead.
Connect to your Pi
From any other machine:
ssh [email protected]
# or
ssh [email protected] # example address: use your Pi's own
Replace username with whatever you set during install. The .local mDNS hostname only works on networks that support mDNS (most home networks do); if it fails, find the IP from your router or by running hostname -I on the Pi via a connected monitor.
First connection prompts for the host key fingerprint: type yes, then enter your password (or use your SSH key if you set one in Imager).

If the connection fails: the real messages and what they mean
The messages below come from the OpenSSH client, so they look the same whatever the server is. They were reproduced on an Ubuntu test VM in the ReadTheManual lab on 15 November 2026 (a username alex, a hostname of raspberrypi.local that does not exist, and the documentation-range address 192.0.2.1), not on a Pi. The causes and fixes are the Raspberry Pi ones.

.local name does not resolve, a connection to an address nothing answers on times out after 8 seconds, and a connection to a host with the SSH server stopped is refused.ssh: Could not resolve hostname raspberrypi.local: ...: your computer cannot turn the.localname into an address. The lab VM printed “Temporary failure in name resolution”; the words after the colon depend on your system’s resolver. Raspberry Pi’s remote access documentation says the.localname works “if your device supports mDNS”. Fixes: check the hostname you set in Imager (it replacesraspberrypi), look up the Pi’s address in your router’s device list and use that, or runhostname -Ion the Pi with a monitor attached.ssh: connect to host <address> port 22: Connection timed out: the packets are going nowhere. Usual causes: the wrong address, the Pi has not joined the network (wrong Wi-Fi details or a first boot that is still running; the getting started guide says it “can take a few minutes”), or the two devices are on different networks, such as a guest Wi-Fi that isolates clients. SSH being switched off does not cause a timeout.ssh: connect to host <address> port 22: Connection refused: you reached the Pi but nothing is listening on port 22. This is the message you get when SSH was never enabled, or the Pi is still starting. Enable it with one of the three methods above, or on the Pi runsudo systemctl status ssh.[email protected]: Permission denied (publickey,password), usually after “Permission denied, please try again.”: the Pi is running SSH and rejecting your login. Check the username (there is no defaultpiuser any more), retype the password, and if you chose public key authentication in Imager, use the matching private key; with key-only set up, the list in brackets is just(publickey)and a password will never be accepted.WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!: you re-flashed the card and the Pi has a new host key. See “When the SD card has been used before” below to clear it.

SSH_ASKPASS helper script, so the screenshot shows no typing) to a server that allows keys and passwords: Permission denied, please try again. twice, then Permission denied (publickey,password). Ubuntu 24.04.5 test VM.The companion 20 Common SSH Errors guide covers more of these with a screenshot for each.
What to do next on a Pi specifically
The same hardening sequence applies as for any Linux server:
- Switch to SSH key auth: the SSH Key Authentication on Ubuntu guide applies identically to Pi OS.
- Disable password auth once keys work: see the SSH Hardening guide.
- Add fail2ban: particularly important for Pis exposed to the internet: see Fail2ban for SSH.
- Consider Tailscale or NetBird instead of port-forwarding. A mesh VPN gets you remote access without exposing port 22 to the open internet at all. Far safer for a Pi at the allotment or family member’s house.
Pi-specific quirks
SSH on Pi Zero / Pi Zero 2 W
Identical mechanics, but the WiFi-only Pi Zero models are slow on busy networks. If SSH feels laggy, check the Pi’s link speed (Raspberry Pi’s documentation uses NetworkManager’s nmcli for network details; nmcli dev wifi list, the command in its configuration documentation, marks the network you are on with * and shows its RATE and SIGNAL. The older iwconfig comes from the separate wireless-tools package, which may not be installed, so prefer nmcli).
SSH on a freshly-imaged Pi 5
Pi 5 boots faster than older Pis, but the first boot still does a lot: it applies the settings from Imager, expands the filesystem to fill the card and brings the network up. Raspberry Pi’s getting started guide warns that first boot “can take a few minutes”, so give it that long before you decide SSH has failed.
Pi OS Lite vs Pi OS with Desktop
Both have identical SSH behaviour. The Lite version skips the desktop environment but openssh-server is in both.
When the SD card has been used before
If you re-flash a card that’s been in another Pi, ~/.ssh/known_hosts on your client will have the old host key cached. You’ll get “Host key verification failed” on first connection. Clear it with:
ssh-keygen -R raspberrypi.local
ssh-keygen -R 192.0.2.100 # or whatever IP the new Pi has
Then reconnect and accept the new fingerprint.
Frequently asked questions
Why is SSH disabled by default on Pi OS?
Historical: early Pi images shipped with pi:raspberry as fixed credentials and SSH on. Anyone scanning home networks could trivially log into thousands of Pis. The Foundation locked SSH off by default to fix this. The user-set credentials and SSH-off-by-default are the remediation.
Can I enable SSH without taking the SD card out?
Yes if you can get a terminal open on the Pi (monitor + keyboard, or via the desktop GUI’s terminal app). Run sudo raspi-config and follow Method 1.
If the Pi is fully headless and you don’t have a console, you have to either pull the SD card and use Method 2, OR re-flash with Imager pre-config.
Does this work on Ubuntu running on a Pi?
The Enable SSH on Ubuntu Server guide applies if you’re running Ubuntu Server for ARM on a Pi instead of Pi OS. Mechanics there match standard Ubuntu (apt install openssh-server, ssh.socket on 24.04, etc). Pi OS uses a different default and the methods on this page.
What’s the default SSH port on Pi OS?
22, same as everywhere. Pi OS doesn’t change defaults for SSH.
My Pi is on a different subnet: how do I find it?
If .local resolution fails, options:
- Check your router’s DHCP client list for the Pi’s MAC address.
- From the Pi (with a monitor temporarily attached), run
hostname -I. - Use
nmapfrom another machine:sudo nmap -sn 192.0.2.0/24lists every device on the subnet (swap in your own network range; 192.0.2.0/24 is a documentation example).
Do I need to open a port on my router?
Only if you want to SSH into the Pi from outside your home network. For LAN-only access, no. For external access, the safer route is Tailscale or another VPN, not port-forwarding 22 to the public internet.
Where you’ll meet this at work
A headless Pi reached over SSH with a key is a small version of how admins reach Linux servers they never touch. In Azure, Azure Bastion provides SSH to Linux VMs through the portal or a native client, and Microsoft Entra ID sign-in for Linux VMs swaps copied keys for OpenSSH certificates tied to a work identity. The certificate model is plain OpenSSH, described in the ssh-keygen manual. First-boot setup maps too: Imager’s Customisation tab does the same job for a Pi that cloud-init does for an Azure Linux VM, which is to set up users, keys and packages as the machine first starts.
What does not map: Imager writes settings onto one card for one device. There is no central inventory, approval step or audit trail, and those are what the enterprise products add. What the home version does teach is the habit that carries over: never leave a login on its default, and put your own key in before the device is on a network.
Companion guides: Enable SSH on Ubuntu Server, SSH Key Authentication, SSH Hardening, Fail2ban for SSH.
The Complete SSH Series
Getting connected
- Enable SSH on Ubuntu Server
- Enable SSH on Raspberry Pi (you are here)
- SSH Essentials: Remote Administration
- SSH from Windows to Ubuntu
Authentication and hardening
File transfer and tunnelling
Reference
Before you expose any of this: the seven steps that decide whether a home lab survives contact with the internet, in the order they matter, are in How to Secure a Homelab Network in 2026.
RTFM Apparel · printed in the UK

ReadTheManual is run, written and curated by Eric Lonsdale.
Eric has over 20 years of professional experience in IT infrastructure, cloud architecture, and cybersecurity, but started with PCs long before that.
He built his first machine from parts bought off tables at the local college campus, hoping they worked. He learned on BBC Micros and Atari units in the early 90s, and has built almost every PC he’s used between 1995 and now.
From helpdesk to infrastructure architect, Eric has worked across enterprise datacentres, Azure environments, and security operations. He’s managed teams, trained engineers, and spent two decades solving the problems this site teaches you to solve.
ReadTheManual exists because Eric believes the best way to learn IT is to build things, break things, and actually read the manual. Every guide on this site runs on infrastructure he owns and maintains.
Enjoyed this guide?
New articles on Linux, homelab, cloud, and automation every 2 days. No spam, unsubscribe anytime.






