Verify the SSH Service Status
The most common reason for connection refusal is that the sshd service has not started or failed during boot. On Ubuntu Server 23.10, the OpenSSH server package must be installed and active. Begin by accessing the console directly via HDMI monitor and keyboard, or use the serial console if available, since remote SSH is currently unavailable.
Check the status of the service using the following command:
sudo systemctl status ssh
If the service is inactive or failed, start it manually with sudo systemctl start ssh. To ensure it starts automatically on boot, enable it with sudo systemctl enable ssh. If the service fails to start, check the logs for specific errors using journalctl -u ssh -e. Common issues include missing host keys or permission errors on configuration files.
Confirm Network Connectivity and IP Address
Before troubleshooting SSH specifically, ensure your Raspberry Pi has a valid IP address and can communicate on the network. Ubuntu Server may default to DHCP, which can assign an IP outside your router's expected range or change upon reboot.
Find the current IP address by running:
ip addr show
Look for the inet address under your active network interface (usually eth0 for wired or wlan0 for wireless). If no IP is assigned, verify that your router's DHCP server is functioning. For persistent access, consider configuring a static IP address in /etc/netplan/ configuration files. Without a reachable IP, no amount of SSH debugging will succeed.
Test Local and Remote Access
Determine if the issue is local to your client machine or specific to the Pi. First, test connectivity from the Pi itself using ssh localhost. If this works, the SSH daemon is listening correctly. If it fails locally, the problem is internal to the Pi's configuration.
Next, test from another device on the same network using ssh username@. Replace username with your actual user account name. If this times out, the connection is blocked by a firewall or the device is unreachable. If it refuses the connection, check if port 22 is open. You can scan the port using nmap or nc -zv .
Check Firewall and Security Settings
Ubuntu Server often includes ufw (Uncomplicated Firewall) pre-installed. If enabled, it may block incoming SSH traffic. Check the firewall status with:
sudo ufw status
If the status is active, allow SSH traffic by running sudo ufw allow ssh. This rule opens port 22 for both IPv4 and IPv6. If you have customized your firewall rules, ensure they explicitly permit TCP traffic on port 22 from your subnet. Remember to reload the firewall after making changes with sudo ufw reload.
Review Authentication Configuration
Ubuntu Server 23.10 enforces strict security defaults. Password authentication might be disabled by default, requiring key-based authentication. Check the main configuration file at /etc/ssh/sshd_config. Look for the line PubkeyAuthentication yes and ensure PasswordAuthentication is set to yes if you intend to use passwords.
After modifying sshd_config, restart the SSH service with sudo systemctl restart ssh. Also, verify that your user account has a proper shell defined in /etc/passwd. If the shell path is incorrect or missing, SSH connections may fail silently. Additionally, ensure that the user is not locked out; you can check this with passwd -S username.
If you are still experiencing difficulties, consider reading our detailed guide on Troubleshooting SSH Connection on Raspberry Pi for more advanced diagnostic steps. Another useful resource is the SSH Connection Refused: Troubleshooting Guide for Tech Support which covers specific error codes.
Frequently Asked Questions
Why does SSH refuse to connect even though the IP is correct?
This typically indicates that the SSH daemon is not listening on port 22 or a firewall is blocking the traffic. Verify the service is running with systemctl status ssh and ensure ufw allows SSH connections. Check the server logs for any binding errors that prevent the daemon from starting.
How do I enable password authentication on Ubuntu Server 23.10?
Edit /etc/ssh/sshd_config and set PasswordAuthentication yes. You must also ensure PermitRootLogin is configured according to your security needs. After saving the file, restart the SSH service to apply the changes immediately.
Can I use SSH over IPv6 on my Raspberry Pi?
Yes, provided your network supports IPv6 and the SSH daemon is configured to listen on IPv6 addresses. Ensure ListenAddress :: is uncommented in sshd_config. Refer to our guide on setting up public IPv6 for more details on network configuration.
What should I do if I lose SSH access completely?
Access the Pi locally via HDMI and keyboard to reset configurations. If you cannot access the console, remove the SD card and mount it on another Linux machine to edit the sshd_config or disable the firewall. This physical access is crucial when remote troubleshooting fails.
Is it safe to disable root login via SSH?
It is highly recommended to disable direct root login for security reasons. Instead, log in as a standard user and use sudo for administrative tasks. This prevents brute-force attacks targeting the root account directly while maintaining full system control.