Enable SSH Raspberry Pi: Quick Setup Guide
In this article
To enable SSH on a Raspberry Pi, you can create an empty file named ssh in the boot directory of the SD card (headless setup) or run sudo raspi-config and enable SSH under Interface Options. This guide walks you through both methods, connecting from another computer, and common troubleshooting.
Why Enable SSH on a Raspberry Pi?
SSH (Secure Shell) gives you a command-line terminal on the Pi from any computer on the same network. It is the standard way to manage a Pi without needing a monitor, keyboard, or mouse. With SSH you can run commands, install software, edit configuration files, and reboot the device remotely. This is essential for headless projects like home servers, network monitors, or IoT devices.
What You Need Before Starting
- A Raspberry Pi (any model, including Zero, 3, 4, or 5) with a microSD card containing Raspberry Pi OS (or another Linux distribution).
- Power supply for the Pi.
- Network connection: Ethernet cable or Wi-Fi credentials (for headless setup, you must preconfigure Wi-Fi on the SD card).
- Another computer (Windows, macOS, or Linux) on the same network to connect from.
Method 1: Headless Setup (No Monitor)
If you are installing Raspberry Pi OS on a fresh SD card and do not want to connect a monitor, you can enable SSH by placing a file on the boot partition.
- Insert the SD card into your computer. It will appear as two volumes:
boot(FAT32, readable by any OS) androotfs(Linux filesystem, often not accessible from Windows/macOS). - Create a new empty file named
ssh(no extension) inside thebootvolume. On Windows, use Notepad and save as type "All Files" with the namessh. On macOS/Linux, usetouch /Volumes/boot/ssh(adjust the mount point). - If you need Wi-Fi, also create a
wpa_supplicant.conffile in the same folder (only for older Raspberry Pi OS versions; newer ones use a different method). For current versions, use the Raspberry Pi Imager to preconfigure Wi-Fi and SSH directly. - Safely eject the SD card, insert it into the Pi, and power it on. The Pi will detect the
sshfile and enable the SSH server automatically.
Method 2: Using raspi-config
If you already have a Pi running with a monitor and keyboard, or you can access it via serial console, use the built-in configuration tool.
- Open a terminal on the Pi.
- Run
sudo raspi-config. - Select Interface Options → SSH → Yes.
- Exit and reboot if prompted.
Connecting to Your Raspberry Pi
Once SSH is enabled, you need the Pi's IP address. If you have a monitor, run hostname -I. Otherwise, check your router's DHCP client list or use a network scanner app.
From your computer, open a terminal (Linux/macOS) or Command Prompt/PowerShell (Windows 10/11). Then run:
ssh pi@<IP_ADDRESS>
The default username is pi and the default password is raspberry (for Raspberry Pi OS with desktop/lite images). On newer images (since late 2022), you are forced to create a custom user during first boot, so use that username and password.
If you are using Windows, you can also use PuTTY (a free SSH client) or the built-in OpenSSH client.
Common Issues and Fixes
- Connection refused: SSH is not enabled. Double-check the
sshfile is present and named correctly (no .txt extension). If you used raspi-config, ensure you selected Yes. - Permission denied: Wrong username or password. Try the default
pi/raspberryor the custom credentials you set during first boot. If you changed the password and forgot it, you may need to reflash the SD card. - Host key verification failed: This happens when the Pi's SSH key changes (e.g., after reflashing). Clear the old key with
ssh-keygen -R <IP_ADDRESS>on Linux/macOS, or delete the entry from PuTTY's cache. - Network unreachable: Ensure the Pi and your computer are on the same network. Check Wi-Fi credentials and that the Pi actually connected to the router.
- SSH service not running: On Raspberry Pi OS, the service is
ssh. Check withsudo systemctl status ssh. If it is not running, start it withsudo systemctl start ssh.
Security Considerations
SSH is a remote access tool, so leaving it open to the internet is risky. The default password is well-known, so change it immediately with passwd. For better security, set up SSH key authentication and disable password login. Never expose port 22 to the public internet unless you have a strong firewall and key-only authentication. On a local network, the risk is lower, but still change the password.
Alternatives to SSH
If SSH does not fit your needs, consider:
- VNC: Provides a graphical desktop over the network. Enable it via raspi-config → Interface Options → VNC.
- Serial console: Connect via a USB-to-UART cable for a text console without network.
- Raspberry Pi Connect: A newer official service that allows remote access over the internet (requires a Raspberry Pi account).
Frequently Asked Questions
How do I enable SSH on Raspberry Pi without a monitor?
Create an empty file named ssh in the boot partition of the SD card before first boot. This works on all Raspberry Pi OS versions.
Why is SSH not working on my Raspberry Pi?
Common causes: the ssh file is missing or has a .txt extension, the Pi is not on the network, or the SSH service is not running. Check the file, the IP address, and run sudo systemctl status ssh.
What is the default password for Raspberry Pi SSH?
The default username is pi and password is raspberry on older images. Newer images require you to create a user during first boot, so use that username/password.
Can I enable SSH by editing config.txt?
No, SSH is not controlled by config.txt. You must use the ssh file or raspi-config.
How do I find my Raspberry Pi's IP address?
Run hostname -I on the Pi if you have access. Otherwise, check your router's device list or use a tool like Advanced IP Scanner.
Is SSH enabled by default in Raspberry Pi OS?
No, it is disabled by default for security. You must enable it manually using one of the methods above.