Skip to main content
All CollectionsVPSVPS Management
How to Troubleshoot SSH Connection Issues on VPS
How to Troubleshoot SSH Connection Issues on VPS

Common SSH connection issues and troubleshooting steps

Updated over 2 months ago

1. Prerequisites

Before troubleshooting the SSH connection, let’s review the requirements first. You will need access to:

- Active Hostinger VPS

- SSH Client (PuTTY, macOS Terminal, Linux shell, etc.)

- Root access credentials (password or SSH keys)

- IP address of the VPS

- Basic knowledge of command-line interface (CLI)

2. SSH Connection Troubleshooting Steps

Step 1: Check VPS Status

Access Hostinger's VPS hPanel and confirm the VPS status is "Running". Restart the VPS if necessary.

Step 2: Check Login Credentials

One of the most frequent reasons for SSH connection failures is the use of incorrect login credentials. SSH requires both a correct username and password (or key) to authenticate, and even small mistakes can prevent a successful connection.

2.1. Ensure the Correct Username

For Hostinger VPS setups, the default username to log in via SSH is root, which grants full administrative access to your server.

When running your SSH command, ensure it’s formatted like this: ssh root@your_vps_ip

2.2. Confirm the Correct Password

Using the correct password is critical, but issues can arise when copying and pasting the password from a password manager or document. For example:

  • Whitespace Issues: Copy-pasting the password might accidentally include extra spaces, which would cause the login to fail.

  • Password is not shown in the terminal: Terminals typically do not display any characters when you enter a password, leaving the field blank. This is normal behavior and part of standard security practices. Even though you don't see anything being typed, the password is still being entered. Keep this in mind when logging in especially while copy-pasting your password.

Recommendation: Instead of copy-pasting, try manually typing the password into the terminal. This helps ensure that no extra spaces or formatting issues interfere with the login.

2.3. Reset the SSH Password or SSH Configuration if Needed

If you're unsure of the password or if it has been changed or forgotten, you can reset it easily through Hostinger’s hPanel.

2.4. Additionally, you can easily reset your SSH Configuration to the initial state.

This resets any changes made to the /etc/ssh/sshd_config file and replaces it with the default configuration file.

Step 3: Test SSH Connection from a Browser Terminal

Hostinger provides an in-browser noVNC terminal that allows you to access your VPS directly from the hPanel without needing an external SSH client. This is a convenient option if you're facing issues with your local SSH client or want quick access to your server.

Navigate to the browser terminal from the VPS hPanel:

Step 4: Confirm IP Address and Domain Configuration

When you reinstall your VPS or change the data center location (e.g., to FR or LT), the server's IP address will change. This will affect your ability to connect via SSH or make your domains unreachable if they are still pointing to the old IP address.

Moving your VPS to a different data center means it’s physically hosted in a new location, which usually comes with a new IP address.

Update DNS records if necessary, ensuring the domains point to the new IP.

If your DNS records were previously pointing to the old IP address, they will no longer resolve correctly after the IP change. To fix this, you must update the DNS records to reflect the new IP.

Step 5: Verify Firewall Configurations

Common reasons for SSH connection issues are firewall or network configurations that block access to port 22 (the default port used by SSH). This could happen either on your VPS, your local machine, or even on your network. Here’s how to ensure everything is properly configured.

5.1. Ensure Port 22 is Open in the VPS Firewall Settings

Your VPS may have a firewall enabled, which could be blocking SSH connections on port 22. You need to confirm that the firewall allows traffic through this port.

1. Log in to your VPS using Hostinger's browser-based terminal.

2. Check the Firewall Status by running the following command to see if port 22 is open:

For Ubuntu / Debian / CloudLinux / AlmaLinux / Rocky Linux / CentOS / Fedora Cloud:

sudo ufw status

If the firewall is active, you will see a list of rules. Check for a line that allows traffic on port 22 (it will look like 22/tcp ALLOW).

For Alpine Linux:

sudo iptables -L

Check for an entry in the INPUT chain allowing traffic on port 22.

For Arch Linux / Kali Linux:

sudo firewall-cmd --list-all

Check if port 22 is listed under allowed services or ports.

3. If Port 22 Is Not Open, you can open it by running:

For Ubuntu / Debian / CloudLinux / AlmaLinux / Rocky Linux / CentOS / Fedora Cloud:

sudo ufw allow 22/tcp

For Alpine Linux:

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

sudo /etc/init.d/iptables save

For Arch Linux / Kali Linux / openSUSE:

sudo firewall-cmd --permanent --add-port=22/tcp

4. Reload the Firewall to apply the changes:

For Ubuntu / Debian / CloudLinux / AlmaLinux / Rocky Linux / CentOS / Fedora Cloud:

sudo ufw reload

Arch Linux / Kali Linux / Fedora Cloud / openSUSE:

sudo firewall-cmd --reload

Once done, SSH should be allowed through port 22 on your VPS, and you can try connecting again.

5.2. Check Network-Level Restrictions

If you're on a restricted network (such as at work or public Wi-Fi), the network administrator might block SSH traffic on port 22. If possible, try connecting from a different network or reach out to the network admin to see if SSH access can be enabled.

If the connection still fails, double-check any third-party firewall software or routers that might be blocking your traffic.

3. Monitor Failed Login Attempts

It's important to keep an eye on any suspicious login attempts. The lastb command allows you to monitor failed login attempts on your server, giving you insights into potential security threats.

Run the following command to see a list of failed login attempts: sudo lastb

Regularly checking this log can help you spot any brute-force attack patterns or unauthorized attempts to access your server. You can use this information to block offending IP addresses or tighten your server’s security settings.

4. Additional Resources

Did this answer your question?