DEV Community

dpm_bush
dpm_bush

Posted on Originally published at sshflow.com

SSH Into a Raspberry Pi: A Practical Connection Checklist

Connecting to a Raspberry Pi over SSH comes down to three things: SSH must be enabled on the Pi, you need an address your computer can reach, and you must use the Pi’s actual login account. If one of those is wrong, the error message can point you in the wrong direction.

Prepare the Pi before connecting

For a new or headless setup, Raspberry Pi Imager can configure remote access while writing Raspberry Pi OS to the SD card. Set a username and password, configure Wi-Fi if needed, and enable SSH in the remote-access settings. You can also choose key-based authentication if you have already prepared a public key.

Keep track of the username you set. Do not assume it is pi: a new installation may use a different account.

If the Pi is already running and you can use its desktop, enable SSH in Raspberry Pi Configuration under its Interfaces settings. From a terminal on the Pi, you can open the configuration menu with:

sudo raspi-config
Enter fullscreen mode Exit fullscreen mode

Choose Interface Options, then SSH, and enable the SSH server. Menu wording may vary by Raspberry Pi OS version. On a systemd-based installation, you can also enable and start the service with:

sudo systemctl enable --now ssh
Enter fullscreen mode Exit fullscreen mode

Run that command on the Pi itself—not on the computer you will connect from.

Find an address your computer can reach

If you have local terminal access to the Pi, check its assigned addresses with:

hostname -I
Enter fullscreen mode Exit fullscreen mode

Use an address on a network your client can reach. You can also look in your router’s connected-device or DHCP-client list. If the router assigns addresses dynamically, the Pi’s IP may change after a reboot.

You can try the Pi’s hostname instead of its IP. The default hostname may be raspberrypi, so a local name could be raspberrypi.local; for a custom hostname, try that name followed by .local. This depends on mDNS and the network, so hostname discovery is not guaranteed. If it fails, try the current IP address. This guide to connecting to an IP address over SSH covers the same address format and related connection options.

Also check that both devices are on a network that allows them to communicate. Guest Wi-Fi or client isolation can prevent devices on the same router from reaching each other.

Connect from your computer

Open PowerShell or Windows Terminal on Windows, Terminal on macOS, or a terminal on Linux. Run the command on that computer, replacing the example values with the account and address for your Pi:

ssh your-user@192.168.1.50
Enter fullscreen mode Exit fullscreen mode

Or, if the hostname resolves on your network:

ssh your-user@raspberrypi.local
Enter fullscreen mode Exit fullscreen mode

The part before @ is the username on the Pi, not necessarily the username on your laptop. If you’re unsure which account belongs in the command, this explanation of how SSH usernames work can help.

Windows, macOS, and Linux can all use the OpenSSH ssh command. If Windows says ssh is not recognized, check whether the OpenSSH Client optional feature is installed.

Understand the first connection prompt

On the first connection, SSH may display a host-key fingerprint and ask whether you trust the host. The key lets your client identify the server on later connections. If you are connecting to the Pi you intended to reach and can verify it, accept the prompt to save its host key.

Do not accept a changed or unexpected identity automatically. If you cannot verify that you are reaching the right device, stop and check the address or fingerprint through a trusted route.

After the host-key prompt, enter the password for the Pi account—not your computer’s password. The terminal will not show characters as you type; that is normal. If the account is set up for key authentication, SSH uses the matching private key on your client instead.

Once connected, confirm which machine and account you reached:

hostname
whoami
Enter fullscreen mode Exit fullscreen mode

Diagnose the error before changing settings

The message usually helps narrow down which part of the setup to check:

  • Could not resolve hostname: Check the spelling and try the Pi’s IP address. Local hostname discovery may not be available on your network.
  • Connection timed out: Confirm that the Pi is powered on and reachable, then check its current address in the router. Guest Wi-Fi or client isolation may block communication.
  • Connection refused: The address may be right while the SSH service is disabled or not running. If you can access the Pi locally, check the service with sudo systemctl status ssh.
  • Permission denied: Check the Pi account name and the password or key you configured. Don’t assume the username is pi.

If the service is not running on a systemd-based installation, start and enable it on the Pi with sudo systemctl enable --now ssh. If it is active, recheck the address and network path rather than changing authentication settings at random.

Avoid exposing SSH to the public internet as a quick fix for a connection problem on your local network. Once you have confirmed access, you can optionally set up key-based authentication for future logins.

I originally published a more detailed version of this guide on the SSHFlow blog.

I'm also building SSHFlow — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.

Top comments (0)