If you want to use your Raspberry Pi “headless”, that is, without monitor or keyboard, the first thing you need is SSH access from your computer. This guide shows how to leave SSH enabled before the first boot with Raspberry Pi OS (Trixie and Bookworm), how to find the Raspberry on your network and what to do when the connection fails.
It used to be enough to create an empty file called ssh on the card and log in as user pi. Today the system no longer ships that default user and the first boot has changed, so the recommended method is different.
Before you start
- A microSD card (or an SSD/USB drive if your model boots from it).
- A computer with Raspberry Pi Imager version 2.0 or later.
- A connection to the same network as the Raspberry: Ethernet cable or your Wi-Fi details.
- An SSH client: Linux, macOS and Windows 10/11 already include
sshin the terminal.
Method 1: Raspberry Pi Imager (recommended)
This is the simplest way and the one the official documentation proposes, because it configures the user, Wi-Fi and SSH at once.
- Open Raspberry Pi Imager and choose your Raspberry Pi model, the operating system (for example, Raspberry Pi OS Lite 64-bit) and the target card.
- When Imager offers to customize the system, fill in the hostname, username and password, time zone and, if you will use Wi-Fi, the network name, password and country.
- In Customisation › Remote Access turn on Enable SSH and choose password or public key authentication.
- Write the image, put the card into the Raspberry and power it up. The first boot takes a couple of minutes while it applies the settings.
If you choose public key authentication, Imager can use the key you already have on your computer (~/.ssh/id_ed25519.pub, for example). It is safer than a password and saves you typing it every time.
Keep in mind that Raspberry Pi OS Trixie images published since late November 2025 use cloud-init for initial setup, and Imager versions older than 2.0 cannot customize them: with an old version the card boots without your user, Wi-Fi or SSH. Update Imager.
Method 2: an ssh file in the boot partition
If you already wrote the card and only need to enable SSH, the classic method still works: create an empty file called ssh (no extension) in the boot partition, the FAT32 partition your computer mounts when you insert the card (inside the system it is /boot/firmware).

From a macOS or Linux terminal, with the card mounted (adjust the volume path, usually called bootfs):
touch /Volumes/bootfs/ssh # macOS
touch /media/$USER/bootfs/ssh # Linux
On Windows you can create an empty text document, name it ssh and make sure it does not stay as ssh.txt (enable “File name extensions” in File Explorer to check).
Note: this file only enables the SSH server. If the image has no user configured, you cannot log in. So if you skip Imager customization, you also need method 3.
Method 3: edit cloud-init by hand (Trixie)
Recent Trixie images include three new files in the boot partition: meta-data, user-data and network-config. You can edit them with any text editor before the first boot. They are YAML, so respect the space indentation.

A minimal user-data to create a user and enable SSH, based on the official example:
#cloud-config
hostname: mypi
manage_etc_hosts: true
timezone: America/New_York
users:
- name: youruser
groups: users,adm,dialout,audio,netdev,video,plugdev,cdrom,games,input,gpio,spi,i2c,render,sudo
shell: /bin/bash
lock_passwd: false
plain_text_passwd: change-this-password
ssh_authorized_keys:
- ssh-ed25519 AAAA... your-public-key
enable_ssh: true
The first line, #cloud-config, is mandatory. If you use a public key, you can remove the plain text password and disable password login with ssh_pwauth: false. Wi-Fi is configured in network-config; I explain it in the guide to Wi-Fi on Raspberry Pi OS Lite.
On Bookworm images, the equivalent was the userconf.txt file in the boot partition, in the format user:encrypted-password.
Find the Raspberry’s IP address
Once the Raspberry has booted, try its name from your computer first. Raspberry Pi OS announces the hostname on the local network via mDNS:

ping raspberrypi.local
Replace raspberrypi with the hostname you set in Imager. If it does not answer, check the connected devices list on your router or scan the network (adjust the range to yours):
sudo nmap -sn 192.168.1.0/24
Connect over SSH
ssh youruser@raspberrypi.local
The first time it asks whether you trust the host fingerprint: answer yes. Then type the password (or you get straight in with a public key).
Check that it works
Once inside, confirm the service is running and what IP the Raspberry has:
systemctl status ssh
hostname -I
If you ever need to enable or disable SSH from the system itself, use sudo raspi-config under 3 Interface Options › I1 SSH.
Common problems
Permission denied even though the password is right. The image does not have the user you are trying. Since 2022 there is no default pi user with password raspberry: create the user with Imager or user-data.
Connection refused. The SSH server is not running. Check that the ssh file is not named ssh.txt or that enable_ssh: true is in user-data, and reboot.
raspberrypi.local does not resolve. Some networks (and some Windows without mDNS support) do not resolve .local names. Use the IP shown by your router.
REMOTE HOST IDENTIFICATION HAS CHANGED warning. You reinstalled the system and the Raspberry has a new fingerprint. Remove the old one from your computer and connect again:
ssh-keygen -R raspberrypi.local
Imager customization was not applied. Common with Imager versions older than 2.0 and Trixie images with cloud-init. Update Imager and write the card again.
Frequently asked questions
Can I use remote desktop instead of SSH? Yes. Imager can also set up Raspberry Pi Connect, the official remote access service, but for managing a Lite version SSH remains the most practical.
Is it safe to leave SSH enabled? On your local network, with a strong password or better, public key only, yes. Do not open port 22 to the outside on your router.
Related
- Set up Wi-Fi on Raspberry Pi OS Lite
- Set a static IP on Raspberry Pi OS
- Update Raspberry Pi OS and firmware
- Which Raspberry Pi to buy: Pi 5, Pi 4 or Zero 2 W



