Can't connect to SSH on a Raspberry PI

Abstract: Resolve SSH connection failures on Raspberry Pi by enabling the sshd service, verifying network IP configuration, and allowing port 22 through firewall rules.

Created: 2026-08-27 by

SSH connection failures on a Raspberry Pi typically stem from the SSH service being disabled, incorrect network configuration, or firewall restrictions. Verify that the sshd daemon is active and listening on port 22, ensure the correct IP address is used, and check local firewall rules to allow incoming connections.

Verify SSH Service Status

The most common reason for an inability to connect via SSH is that the service is not running or has been explicitly disabled. On modern Raspberry Pi OS versions, the SSH server is often disabled by default for security reasons. You must first confirm whether the service is installed and currently active.

To check the status of the SSH daemon, open a terminal directly on the Raspberry Pi (using a monitor, keyboard, and mouse) or access it via another method like VNC if available. Run the following command to see the current state:

sudo systemctl status ssh

If the output indicates that the service is inactive or disabled, you need to enable it. Use the following commands to start the service immediately and ensure it starts automatically on boot:

sudo systemctl enable ssh
sudo systemctl start ssh

After running these commands, verify the status again. The output should show "active (running)" with green text. If the service fails to start, check the journal logs for specific error messages using journalctl -u ssh. This will provide details on why the daemon could not initialize, such as missing host keys or permission issues.

Check Network Configuration and Connectivity

Even if the SSH service is running, network misconfigurations can prevent external devices from reaching the Raspberry Pi. Ensure that both the client device and the Raspberry Pi are connected to the same local network. If you are using Wi-Fi, verify that the Pi has obtained a valid IP address.

Use the hostname -I command in the terminal to display the IP address assigned to the Raspberry Pi. Note this address carefully. It is crucial to distinguish between IPv4 and IPv6 addresses; most standard SSH clients default to IPv4, so ensure you are using the correct IPv4 address.

You can test basic connectivity from your computer by pinging the Raspberry Pi's IP address. Open a terminal on your local machine and run:

ping <Raspberry_Pi_IP_Address>

If the ping is successful, the network path is open. If the ping fails, there may be a network isolation issue, such as AP Isolation enabled on your Wi-Fi router, which prevents devices on the same wireless network from communicating with each other. In such cases, you may need to adjust your router settings or use a wired Ethernet connection.

Inspect Firewall Rules

Firewalls can block incoming SSH connections even when the service is active and the network is reachable. Raspberry Pi OS does not enable a firewall by default, but if you have installed one manually or are using a different operating system, it might be blocking port 22.

If you are using UFW (Uncomplicated Firewall), check its status with:

sudo ufw status

If the status is active, ensure that traffic on port 22 is allowed. You can allow SSH traffic by running:

sudo ufw allow ssh

For firewalld users, similar steps apply to open the SSH service zone. Always remember to reload the firewall configuration after making changes to ensure they take effect immediately.

Authentication and Key Issues

Once the service is running and the network is clear, authentication problems may arise. By default, Raspberry Pi OS allows password authentication. Ensure you are using the correct username (pi for older images, or the custom user created during setup for newer ones) and the correct password.

If you are using key-based authentication, verify that the public key is correctly added to the ~/.ssh/authorized_keys file on the Raspberry Pi. Check file permissions; the .ssh directory should have permissions 700, and the authorized_keys file should have permissions 600. Incorrect permissions will cause the SSH server to reject the key silently.

For detailed debugging, attempt to connect with verbose output from your client machine:

ssh -v pi@<Raspberry_Pi_IP_Address>

This will show exactly where the connection process fails, whether at the network level, key exchange, or authentication stage.

Frequently Asked Questions

Why can I ping my Raspberry Pi but cannot SSH?

Ping uses ICMP protocol, while SSH uses TCP port 22. A successful ping only confirms network layer reachability, not application layer availability. The SSH service itself may be stopped, or a firewall may be blocking TCP port 22 specifically while allowing ICMP.

How do I enable SSH via command line without a GUI?

You can enable SSH remotely using the raspi-config tool. Run sudo raspi-config, navigate to Interface Options, select SSH, and choose Yes to enable it. Alternatively, simply create an empty file named ssh in the root directory of the boot partition if you have SD card access.

What should I do if SSH hangs during connection?

Hanging often indicates a network timeout or DNS resolution issue. Try connecting using the IP address instead of the hostname to rule out DNS problems. Also, check if your router has assigned a static lease to the Pi to prevent IP changes that might confuse persistent connections.

Can I change the default SSH port on Raspberry Pi?

Yes, you can change the port by editing /etc/ssh/sshd_config and modifying the Port directive. After changing the port, restart the SSH service. Remember to update your firewall rules and any client configurations to use the new port number.

Is it safe to disable password authentication for SSH?

Disabling password authentication and using only SSH keys is generally safer as it mitigates brute-force attacks. However, ensure you have a backup method to access the Pi, such as console access, in case you lose your private key or lock yourself out.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More