How to Enable SSH on Raspberry Pi

Secure Shell (SSH) is a network protocol that lets you securely connect to your Raspberry Pi over an encrypted connection without needing a monitor or keyboard attached. With SSH enabled, you can run commands remotely, transfer files using tools like scp
, and manage your Pi from any machine on the network.
Raspberry Pi OS ships with SSH disabled by default. This guide covers three ways to enable it: during OS installation with Raspberry Pi Imager, on a pre-imaged SD card without a screen, and from the desktop or terminal on a running system.
Enabling SSH During OS Installation
The cleanest approach is to configure SSH before you write the SD card. Raspberry Pi Imager handles this through its Customisation settings, so SSH is ready the moment the Pi boots.
Download and install Raspberry Pi Imager for your operating system.
Open Imager, select your Raspberry Pi device, choose Raspberry Pi OS, and select your storage device.
Click Next. If the image supports customisation, Imager opens the Customisation tab.
On the Hostname and User subtabs, set a hostname, username, and password. Current Raspberry Pi OS images no longer include a default account, so these credentials are required.
Open the Remote Access subtab. Turn on Enable SSH and choose password authentication or public key authentication.
To use public key authentication, paste the contents of your
~/.ssh/id_rsa.pubor~/.ssh/id_ed25519.pubfile into the field. If you do not have a key pair yet, generate one first .Continue through any remaining subtabs, save the customisation settings, and write the image to the card.
When the Pi boots from this card, SSH will be active and you can connect immediately using the credentials you configured.
Enabling SSH on a Pre-Imaged SD Card (Headless)
If you already have an SD card with Raspberry Pi OS installed and no monitor available, you can enable SSH by placing an empty file named ssh in the boot partition. The OS checks for this file on startup and enables SSH automatically if it finds it.
This method only enables the SSH service. You still need a configured user account and, for Wi-Fi-only setups, working network settings. For a new headless install, Raspberry Pi Imager is usually safer because it sets the user, network, and SSH options together.
Power off your Raspberry Pi and remove the SD card.
Insert the SD card into your computer. It mounts automatically.
Navigate to the boot partition. On current Raspberry Pi OS images it is usually labeled
bootfs; on older images it may be labeledboot.Create a new empty file named exactly
sshwith no extension.On Linux or macOS, open a terminal and run the following command, replacing the path with your actual mount point:
Terminaltouch /media/$USER/bootfs/sshOn Windows, right-click inside the partition in File Explorer, create a new text file, and rename it to
sshremoving the.txtextension.Eject the SD card, insert it back into the Pi, and power it on. The Pi detects the file on boot, enables SSH, and removes the file automatically.
Enabling SSH With a Monitor Attached
If you have a monitor and keyboard connected, you can enable SSH through the graphical configuration tool, through raspi-config in the terminal, or by starting the service directly with systemctl.
From the Raspberry Pi Configuration Tool
- Open the Raspberry Pi menu and go to Preferences > Control Centre.
- Open the Interfaces tab.
- Turn on the toggle next to SSH.
- Click Close and reboot if prompted.
From raspi-config in the Terminal
Open a terminal and launch the configuration tool:
sudo raspi-configUse the arrow keys to select 3 Interface Options > I1 SSH. Confirm that you want to enable the SSH server, then select OK and Finish.
Alternatively, you can enable and start the SSH service in one step with systemctl:
sudo systemctl enable --now sshConnecting to Raspberry Pi via SSH
Once SSH is running, you need the Pi’s IP address. On the Pi itself, run:
hostname -I192.168.1.42If you are setting up headlessly, check your router’s DHCP client list instead.
From your computer, connect using the ssh command
with the username and IP address you configured:
ssh username@192.168.1.42The first time you connect, SSH displays a fingerprint warning. Type yes to accept it and add the host to your known hosts file.
The authenticity of host '192.168.1.42 (192.168.1.42)' can't be established.
ED25519 key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no/[fingerprint])?Windows users can use the built-in ssh client from PowerShell or Command Prompt, or a graphical client like PuTTY
.
If you are exposing the Pi to the internet, changing the default SSH port reduces automated login attempts. Setting up key-based authentication removes the need to type a password on every connection.
Troubleshooting
Connection refused
SSH is not running or was not enabled on boot. If you have local access, run sudo systemctl status ssh and start it with sudo systemctl enable --now ssh.
No route to host or connection timed out
The Pi is not reachable on the network. Check that it is powered on, connected to Ethernet or Wi-Fi, and using the IP address shown by your router or hostname -I.
Permission denied
The username, password, or SSH key does not match the account configured on the Pi. Recheck the username you set in Raspberry Pi Imager and make sure the public key was copied correctly.
The hostname does not resolve
If raspberrypi.local or your custom hostname does not work, connect with the Pi’s IP address instead.
Conclusion
You now have SSH enabled on your Raspberry Pi and can connect remotely from any machine on the network. To manage connections more easily, define your Pi in the SSH config file so you can connect with a short alias instead of typing the full address each time.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page