Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Setup and OS

First Boot and Headless Setup

Boot your Raspberry Pi for the first time, find its IP address, connect over SSH without a monitor, set up key login and fix common first-boot problems.

You have a card with Raspberry Pi OS on it. Now comes the exciting moment: the first boot. There are two ways to work with the Pi. With a monitor, keyboard and mouse it behaves like a normal desktop computer. In a headless setup there is no screen at all; you reach the board from your laptop over the network. Headless is how most real Pi projects run, so it is worth learning early.

Booting with a monitor

Insert the card, plug in the display, keyboard and mouse, and connect power last. The Pi has no power button on most models; plugging in the supply starts it. You will see a rainbow splash and then text scroll by. On the first start the system resizes its file system to fill the card and may reboot once, so give it a minute. If you configured a user in Imager, you land straight on the desktop; if not, a setup wizard asks for a username, password, Wi-Fi and location.

The green LED flickers while the card is being read. A red power LED that stays on means the board is getting power. If the screen stays black, re-check the HDMI port: the Pi 4 and Pi 5 have two, and the one nearest the USB-C power port is the main one.

Booting headless

If you enabled SSH and Wi-Fi (or plugged in Ethernet) in Imager, simply power the Pi and wait about a minute. Then you need to find its address on your network:

  1. Try the hostname you chose: ping pi5.local. This works through mDNS on most systems.
  2. Look at your router's list of connected devices; the Pi appears with its hostname.
  3. Scan the network from your laptop with a tool such as nmap (read-only):
Terminal
ping raspberrypi.local
nmap -sn 192.168.1.0/24

Once you know the address, connect with SSH (secure shell), which gives you a command line on the Pi from your computer:

Terminal
ssh pi@pi5.local
# or: ssh [email protected]

The first time, SSH asks you to confirm the board's host key fingerprint. Type yes. Then enter the password you set. The prompt changes to pi@pi5:~ $, and every command you type now runs on the Pi.

Headless in four steps

  1. Write the card
With SSH and Wi-Fi on
  1. Power on
Wait about a minute
1 / 2

Key login: safer than passwords

Passwords can be guessed, especially if the Pi is on a network others can reach. An SSH key pair is stronger. You create a pair on your laptop: a private key that never leaves your machine and a public key you copy to the Pi. Read-only commands:

Terminal
ssh-keygen -t ed25519 -C "my-laptop"
ssh-copy-id pi@pi5.local
ssh pi@pi5.local        # no password now

After that works, you may turn off password logins in /etc/ssh/sshd_config (set PasswordAuthentication no) and restart the SSH service. Do this only after you have confirmed that key login works, or you can lock yourself out.

Never leave a Pi on the open internet with the default or a weak password. Automated bots scan the internet constantly for SSH servers. Use a strong password or, better, keys.

A look at what the Pi does at boot

Boot is a chain. The firmware reads the card, loads the kernel, the kernel starts the first process, and services bring up networking and SSH. The diagram shows the order.

flowchart LR
  A["Power on"] --> B["Firmware reads boot partition"]
  B --> C["Kernel loads"]
  C --> D["Init system starts services"]
  D --> E["Network up"]
  E --> F["SSH ready"]

From power to a login prompt in roughly half a minute.

Try it: build an SSH command

A script can assemble the connection command from your answers, which is handy when you manage several boards. The stand-in below builds it and checks the input.

Python Stand-in: build an ssh command

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try it: find the Pi in a list

Routers show many devices. This stand-in scans an example device list for names that look like a Pi. The real MAC address prefix of Raspberry Pi boards identifies them, and the Foundation's registered prefixes include b8:27:eb, dc:a6:32, e4:5f:01 and d8:3a:dd.

Python Stand-in: spot Pis on the network

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

When it does not boot

  • Nothing on screen, no LED. Check power and the supply rating.
  • Red LED on, green never blinks. The card is not readable. Rewrite it or try another card.
  • SSH: connection refused. SSH is not enabled. Re-write the card with SSH on, or create an empty file named ssh in the boot partition.
  • SSH: host not found. The Pi did not join Wi-Fi: wrong password or country. Try Ethernet.
  • Host key changed warning. You reused a hostname for a new install; remove the old entry with ssh-keygen -R pi5.local.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does headless mean on a Pi?

    Headless setups are managed over the network, usually with SSH.
  2. 2. What is the safest way to log in over SSH?

    Keys are much harder to guess than passwords.
  3. 3. SSH says connection refused. What is the most likely cause?

    Refused means nothing is listening on the SSH port; enable SSH and reboot.
  4. 4. Which command finds a Pi called pi5 on most home networks?

    mDNS resolves the .local hostname to the Pi's IP address.

Summary

  • Power the Pi last; it boots automatically.
  • A headless Pi is reached with ssh [email protected] after you configured SSH and network access.
  • Use key-based login and strong passwords.
  • Most boot failures are power, card or Wi-Fi settings problems.

Next: raspi-config and Updates