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?
- Check SSH service status:
Distribution Command systemd-based (Ubuntu 16.04+, CentOS 7+, etc.) sudo systemctl status sshd -lCentOS 6 sudo service sshd statusUbuntu 14.04, Debian 7 sudo service ssh status - If not running, restart the SSH service:
Distribution Command systemd-based sudo systemctl restart sshdCentOS 6 sudo service sshd restartUbuntu 14.04, Debian 7 sudo service ssh restart - If still not running, check logs:
Distribution Command systemd-based sudo journalctl -u sshd -u sshCentOS 6 less /var/log/secureUbuntu/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?
- Check for this error:
Bind to port 22 failed: Address already in use. - Identify conflicting service:
sudo netstat -plntu | grep :22 - 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)
- Backup current rules:
sudo iptables-save > ~/iptables.txt - Allow all traffic:
sudo iptables -P INPUT ACCEPT sudo iptables -P FORWARD ACCEPT sudo iptables -P OUTPUT ACCEPT - Flush rules:
sudo iptables -F sudo iptables -t nat -F sudo iptables -t mangle -F sudo iptables -X - Repeat with
ip6tablesfor IPv6
Troubleshooting Rejected SSH Logins
Is Root Login Allowed?
grep PermitRootLogin /etc/ssh/sshd_config
If set to no, either:
- Change it to
yesand restart SSH - Use another user account
Are Password Logins Enabled?
grep PasswordAuthentication /etc/ssh/sshd_config
If set to no, either:
- Change to
yesand 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.
