How to Enable SSH on Raspberry Pi

By 

Updated on

5 min read

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.

  1. Download and install Raspberry Pi Imager for your operating system.

  2. Open Imager, select your Raspberry Pi device, choose Raspberry Pi OS, and select your storage device.

  3. Click Next. If the image supports customisation, Imager opens the Customisation tab.

  4. 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.

  5. 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.pub or ~/.ssh/id_ed25519.pub file into the field. If you do not have a key pair yet, generate one first .

  6. 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.

  1. Power off your Raspberry Pi and remove the SD card.

  2. Insert the SD card into your computer. It mounts automatically.

  3. Navigate to the boot partition. On current Raspberry Pi OS images it is usually labeled bootfs; on older images it may be labeled boot.

  4. Create a new empty file named exactly ssh with no extension.

    On Linux or macOS, open a terminal and run the following command, replacing the path with your actual mount point:

    Terminal
    touch /media/$USER/bootfs/ssh

    On Windows, right-click inside the partition in File Explorer, create a new text file, and rename it to ssh removing the .txt extension.

  5. 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

  1. Open the Raspberry Pi menu and go to Preferences > Control Centre.
  2. Open the Interfaces tab.
  3. Turn on the toggle next to SSH.
  4. Click Close and reboot if prompted.

From raspi-config in the Terminal

Open a terminal and launch the configuration tool:

Terminal
sudo raspi-config

Use 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:

Terminal
sudo systemctl enable --now ssh

Connecting to Raspberry Pi via SSH

Once SSH is running, you need the Pi’s IP address. On the Pi itself, run:

Terminal
hostname -I
output
192.168.1.42

If 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:

Terminal
ssh username@192.168.1.42

The first time you connect, SSH displays a fingerprint warning. Type yes to accept it and add the host to your known hosts file.

output
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.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

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