Troubleshooting SSH on VPS's

If you're unable to connect to your VPS via SSH, this guide will help you identify and fix the issue.


Before You Begin

Use the VPS Console

The console provides direct shell access to your VPS without requiring network connectivity, making it ideal when SSH is down.

All commands in this guide assume you're using the console.

Forgot Your Password?

If you can’t log in via console due to a forgotten Linux password:

  • Reset the root password via your VPS control panel.
  • Or, if logged in as root, change another user's password:
    passwd <username>

Troubleshooting Unresponsive SSH Connections

If your SSH session times out or is immediately rejected, it could be due to:

  • SSH service not running
  • Firewall blocking the connection

Is SSH Running?

  1. Check SSH service status:
    Distribution Command
    systemd-based (Ubuntu 16.04+, CentOS 7+, etc.) sudo systemctl status sshd -l
    CentOS 6 sudo service sshd status
    Ubuntu 14.04, Debian 7 sudo service ssh status
  2. If not running, restart the SSH service:
    Distribution Command
    systemd-based sudo systemctl restart sshd
    CentOS 6 sudo service sshd restart
    Ubuntu 14.04, Debian 7 sudo service ssh restart
  3. If still not running, check logs:
    Distribution Command
    systemd-based sudo journalctl -u sshd -u ssh
    CentOS 6 less /var/log/secure
    Ubuntu/Debian less /var/log/auth.log

Is SSH on a Non-Standard Port?

Run:

sudo netstat -plntu | grep ssh

Example output:

tcp  0  0 0.0.0.0:41  0.0.0.0:*  LISTEN  4433/sshd

SSH is listening on port 41. Connect using:

ssh username@your-vps-ip -p 41

Or, edit /etc/ssh/sshd_config and change the port to 22.

Is Another Service Using Port 22?

  1. Check for this error:
    Bind to port 22 failed: Address already in use.
  2. Identify conflicting service:
    sudo netstat -plntu | grep :22
  3. Resolve:
    • Change SSH port
    • Or stop the other service:
      sudo systemctl stop <service>
      sudo systemctl disable <service>

Check and Manage Firewall Rules

View Firewall Rules

sudo iptables-save
sudo ip6tables-save
sudo ufw status
sudo firewall-cmd --state

Sample rule that allows SSH:

-A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT

Temporarily Disable Firewall (for testing only)

  1. Backup current rules:
    sudo iptables-save > ~/iptables.txt
  2. Allow all traffic:
    sudo iptables -P INPUT ACCEPT
    sudo iptables -P FORWARD ACCEPT
    sudo iptables -P OUTPUT ACCEPT
  3. Flush rules:
    sudo iptables -F
    sudo iptables -t nat -F
    sudo iptables -t mangle -F
    sudo iptables -X
  4. Repeat with ip6tables for IPv6

Troubleshooting Rejected SSH Logins

Is Root Login Allowed?

grep PermitRootLogin /etc/ssh/sshd_config

If set to no, either:

  • Change it to yes and restart SSH
  • Use another user account

Are Password Logins Enabled?

grep PasswordAuthentication /etc/ssh/sshd_config

If set to no, either:

  • Change to yes and restart SSH
  • Use SSH key authentication

Collect SSH Debug Logs

View Logs

Check /var/log/auth.log, /var/log/secure, or journal logs for login attempts. Search using your IP:

grep "your.public.ip" /var/log/auth.log

Enable SSH Verbose Mode

ssh -v username@your-vps-ip
ssh -vv username@your-vps-ip
ssh -vvv username@your-vps-ip

Summary

  • Check that SSH service is running
  • Ensure the correct port is used and not blocked
  • Review firewall settings
  • Confirm SSH configuration permits your login method
  • Use console when network access is unavailable

Need more help? Feel free to contact our support team.

  • Troubleshooting SSH on VPS's, Troubleshooting SSH on VPS, SSH on VPS
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Access your Folders(Linux/Centos) using WinSCP

Guide on how to access the folders in your vps linux! This is the easiest way, First make sure...

How to traceroute your VPS IP?

How to Use the Traceroute Command Traceroute is a command which can show you the path a...

Command line bandwidth monitors for Linux

If you are a Sysadmin, monitoring bandwidth usage on your server is an important task. We agree...

Check the RAM Usage in Linux

1. Login to your VPS using Putty. 2. Type: free -m

How to do “mysqladmin flush-hosts” on VPS server?

How to fix this error "MySQL Database Error: Host '127.0.0.1' blocked because of many...