keepcalculator

06 Numbers and Powers

Cannot SSH Into Server? Console Fixes

Card No. 06·66832 · Updated · Standard formula, shown below

If you cannot SSH into your server, first try to reach the console through your hosting provider’s web-based terminal or a physical keyboard and monitor, because that is the only way to diagnose and fix the problem when the network path is broken. Once you have console access, you can check the SSH service, firewall rules, and network settings to restore remote access. This article explains the common causes of SSH failures and the exact steps to recover access.

Why SSH Stops Working

SSH is a network protocol that depends on three things working together: the server’s SSH daemon (sshd) is running, the network path from your computer to the server is open, and the server’s firewall allows incoming connections on port 22 (or whatever port you configured). A failure in any of these areas will block your connection. Common triggers include a recent system update that changed firewall rules, a crashed SSH service, a full disk that prevents the daemon from starting, or a misconfigured network interface. Sometimes the problem is on your side—a wrong IP address, a changed SSH key, or a local firewall blocking outbound traffic.

First Steps: Verify Basic Connectivity

Before you panic, run a few quick checks from your local machine. These will tell you whether the problem is the network or the server itself.

  • Ping the server – ping (or ping ). If you get replies, the server is up and reachable at the IP level. If not, the server may be offline, or a network/firewall is blocking ICMP.
  • Check the SSH port – nc -zv 22 (or telnet 22) to see if the port is open. A successful connection shows a banner like SSH-2.0-OpenSSH_.... If the connection times out or is refused, the SSH service is not listening or a firewall is dropping the packets.
  • Try a different network – If you are on a corporate or public Wi-Fi, the network may block port 22. Use your phone’s hotspot to test.
  • Try a different client – Use another SSH client (e.g., PuTTY on Windows, or ssh from a different machine) to rule out a local configuration issue.

If the port is closed, you need console access to fix it.

How to Get Console Access

Console access means interacting with the server directly, bypassing the network. The method depends on your hosting environment.

  • Cloud providers (AWS, Google Cloud, Azure, DigitalOcean, etc.) – Most offer a web-based console in their dashboard. Look for a “Console” or “VNC” button next to your instance. This opens a virtual terminal in your browser, giving you a login prompt (usually with the root user or a default user).
  • Dedicated servers or on-premise hardware – Use a physical keyboard and monitor connected to the server, or use an out-of-band management interface like IPMI or iDRAC if available. These allow remote console access even when the OS is not fully booted.
  • Virtual private servers (VPS) with a control panel – Many VPS providers include a “VNC” or “Console” option in their panel. This is the same as a cloud console.

Once you have a console, log in with your root or sudo user credentials. If you do not know the password, you may need to reset it via the provider’s dashboard (most offer a password reset or key injection feature).

Diagnosing and Fixing the SSH Service

With console access, you can inspect the SSH daemon. Start by checking its status:

  1. Run systemctl status sshd (or service ssh status on older systems). If it shows active (running), the service is fine—move on to firewall checks. If it shows inactive or failed, start it with systemctl start sshd.
  2. If it fails to start, check the logs: journalctl -u sshd or tail -f /var/log/auth.log (on Debian/Ubuntu) or /var/log/secure (on RHEL/CentOS). Common errors include a missing host key, a misconfigured sshd_config, or a full disk.
  3. If the disk is full (check with df -h), free up space by removing old logs or temporary files, then restart sshd.
  4. If you recently edited /etc/ssh/sshd_config, a syntax error can prevent the daemon from starting. Validate it with sshd -t. Fix any errors, then restart.

After starting the service, test locally with ssh localhost from the console. If that works, the issue is likely network/firewall related.

Firewall and Network Configuration

If SSH is running but you still cannot connect, the firewall is the next suspect. On Linux, the common firewalls are iptables, ufw (Ubuntu), and firewalld (RHEL/CentOS).

  • UFW – Check status with ufw status. If active, allow SSH with ufw allow OpenSSH or ufw allow 22/tcp.
  • Firewalld – Use firewall-cmd --list-all to see open ports. Add SSH with firewall-cmd --add-service=ssh --permanent and reload with firewall-cmd --reload.
  • Iptables – List rules with iptables -L -n -v. If you see a DROP rule for port 22, insert an ACCEPT rule before it: iptables -I INPUT -p tcp --dport 22 -j ACCEPT. Save the rules with iptables-save or the distribution’s method.

Also verify the network interface has the correct IP address and is up. Use ip addr to see the assigned IPs. If the IP changed (e.g., DHCP lease expired), your SSH client might be trying the old IP. Update your client or set a static IP.

If you are behind a NAT or using port forwarding, ensure the router forwards port 22 to the server’s internal IP. Also check that your hosting provider’s security group (cloud) or firewall allows inbound TCP on port 22 from your IP.

Authentication Issues: Keys and Passwords

Sometimes the network and service are fine, but your credentials are rejected. This is common after a server restore or when you switch to a new laptop.

  • Password authentication – If you get “Permission denied (publickey,password)”, you may be using the wrong password. Use the console to reset the password: passwd .
  • Key-based authentication – If you have set up SSH keys, the server may reject your key if the public key in ~/.ssh/authorized_keys is incorrect or the permissions are wrong. On the server, check that ~/.ssh has 700 permissions and authorized_keys has 600. Also ensure your private key on your local machine is readable and not corrupted.
  • Root login disabled – Many servers disable root SSH login by default. If you are trying to log in as root and get a rejection, use a regular user and then sudo to root. If you need root SSH, edit /etc/ssh/sshd_config and set PermitRootLogin yes, then restart sshd.

If you are locked out because you lost your private key, use the console to add your new public key to the appropriate authorized_keys file.

What If You Cannot Reach the Console Either?

If the console is also unreachable, the server may be completely offline or the network stack is crashing. Try these steps:

  • Reboot the server from the provider’s dashboard. A forced reboot can clear a hung state.
  • If you have a physical server, check power and network cables, and try a different network port.
  • Use the provider’s “rescue mode” or “recovery console” if available. This boots a minimal Linux environment that lets you mount the disk and fix configuration files.
  • If the server is a VM, check the hypervisor logs for errors.

If none of this works, your hosting provider’s support may need to intervene. Have your account details and any error logs ready.

Preventing Future Lockouts

Once you regain access, take steps to avoid this situation again.

  • Set up a second SSH key and store it safely.
  • Use a configuration management tool (like Ansible) to ensure SSH configs are consistent.
  • Enable a monitoring service that alerts you when SSH is down.
  • Test your firewall rules after every change, and always keep a console session open when making network changes.
  • Consider using a VPN or a jump host for remote access, which adds a layer of security but also a fallback path.

Frequently Asked Questions

Why do I get “Connection refused” when trying to SSH?

“Connection refused” means the server is reachable but nothing is listening on port 22. This usually indicates the SSH daemon is not running, or it is listening on a different port. Check the service status and the Port directive in sshd_config.

What should I do if I forgot my SSH password?

Use the console access to reset the password with the passwd command. If you do not have console access, you may need to use the hosting provider’s password reset feature, which often requires a reboot.

Can I SSH into my server if the firewall is blocking port 22?

No, unless you change the firewall rules. You need console access to allow port 22 through the firewall. Alternatively, if you have another open port (e.g., 443 for HTTPS), you could temporarily use a reverse SSH tunnel, but that requires prior setup.

Why does SSH hang or time out instead of refusing?

A timeout suggests packets are being dropped—likely a firewall rule that silently drops traffic, or a network issue like a wrong IP or a router blocking the port. Check your local firewall and the server’s firewall, and verify the IP address is correct.

Is it safe to enable root login over SSH?

It is generally safer to disable root login and use a regular user with sudo. If you must enable it, use key-based authentication only and disable password authentication for root. This reduces the risk of brute-force attacks.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →