VPS Connection via VPN Successful but SSH Unreachable

Abstract: Resolve SSH unreachable errors after VPN connection by verifying sshd status, binding to correct interfaces, and checking firewall rules.

Created: 2026-08-14 by
You can resolve SSH unreachability after establishing a VPN connection by verifying that the SSH daemon is listening on the correct interface, ensuring your client uses the private IP assigned by the VPN rather than the public one, and confirming that local firewall rules or SELinux policies are not blocking port 22 traffic within the tunnel.

Verify the SSH Daemon Status

The most common cause for this issue is that the sshd service has crashed or failed to start correctly after the network configuration changed due to the VPN connection. Even if the VPS itself is reachable via ping through the VPN, the specific service handling SSH connections may be inactive. You should first establish a console session using your provider's web-based terminal or out-of-band management interface (such as AWS EC2 Instance Connect, DigitalOcean Rescue Mode, or similar tools provided by your host).

Once logged in via the console, check the status of the SSH service using the command systemctl status sshd (or ssh on some older distributions). If the service is inactive or failed, restart it with sudo systemctl restart sshd. Check for any immediate errors in the output. If the service starts successfully, attempt an SSH connection again. If it fails to start, review the journal logs with journalctl -xeu sshd to identify configuration syntax errors or permission issues on keys.

Check Network Interface Binding

SSH servers often bind to specific network interfaces or IP addresses. By default, OpenSSH listens on all available interfaces (0.0.0.0), but some security-hardened configurations restrict it to only the public-facing interface. When you connect via VPN, you are accessing the VPS through its private IP address, which is different from the public IP. If the SSH server is configured to listen only on the public IP, it will ignore packets arriving on the private VPN interface.

To verify this, run ss -tlnp | grep :22 or netstat -tlnp | grep :22 on the VPS. Look at the local address column. If you see 192.168.x.x:22 or 10.0.x.x:22 instead of 0.0.0.0:22, the server is restricted. Edit the /etc/ssh/sshd_config file and ensure the line ListenAddress is either commented out or set to 0.0.0.0. After making changes, restart the SSH service. Additionally, ensure that the AllowUsers or AllowGroups directives do not inadvertently exclude the user account you are trying to access via the VPN tunnel.

Validate Client-Side Connection Parameters

It is critical that your SSH client connects to the correct IP address. Many users mistakenly try to SSH into the public IP of the VPS while the VPN is active, which routes traffic directly over the internet and bypasses the VPN entirely, potentially hitting a firewall that blocks external SSH attempts. Alternatively, if the VPN assigns a gateway IP rather than the VPS's internal IP, you might be connecting to the wrong endpoint.

Identify the private IP address assigned to the VPS within the VPN subnet. This information is usually found in your VPN provider's dashboard or by running ip addr on the VPS console. Use the explicit IP in your SSH command, such as ssh user@. If you are experiencing timeouts, add the -v flag to enable verbose mode (ssh -v user@). This will show exactly where the connection hangs—whether during DNS resolution, TCP handshake, or key exchange—which helps isolate whether the issue is network routing or authentication.

Inspect Firewall and Security Groups

Even inside a VPN, firewalls can block traffic. Your VPS likely runs ufw, firewalld, or iptables. While these typically allow loopback and established connections, they might drop new incoming connections on port 22 if not explicitly permitted for the VPN subnet. Check your firewall status with sudo ufw status or sudo firewall-cmd --list-all. Ensure that port 22 is allowed for the entire subnet used by your VPN (e.g., allow from 10.8.0.0/24) or globally.

Furthermore, if your VPS provider uses cloud-based security groups (like AWS Security Groups or Azure NSGs), these act as a virtual firewall at the hypervisor level. These rules apply regardless of whether you are connected via VPN or the public internet. Verify in your provider's control panel that the security group associated with the VPS instance allows inbound TCP traffic on port 22 from the VPN CIDR range or from anywhere (0.0.0.0/0). If the security group blocks port 22, no amount of local firewall configuration will help. For more details on managing remote connectivity, you might find How to Access IP/Hostname on Windows using SSH Server useful for understanding client-side configurations.

Review SELinux and AppArmor Policies

In Linux distributions like CentOS, RHEL, or Ubuntu with strict profiles, mandatory access controls like SELinux or AppArmor can prevent SSH from binding to non-standard ports or interacting with network interfaces if policies are misconfigured. While rare for standard port 22 usage, a recent update or change in network policy can trigger these restrictions. Check SELinux status with sestatus. If it is enforcing, check audit logs with ausearch -m avc -ts recent for denials related to sshd. If you suspect interference, you can temporarily set SELinux to permissive mode with sudo setenforce 0 to test if it resolves the issue, though this is not a permanent fix.

Frequently Asked Questions

Why can I ping the VPS via VPN but cannot SSH?

Ping uses ICMP protocol, while SSH uses TCP on port 22. Your firewall or security group may allow ICMP traffic for diagnostics but block TCP port 22 for security reasons. You must explicitly permit TCP port 22 in both the local OS firewall and the cloud provider's security group settings.

Should I use the public IP or private IP when connected via VPN?

You should always use the private IP address assigned to the VPS within the VPN subnet. Using the public IP while the VPN is active may route traffic outside the tunnel, leading to connection failures if external SSH access is disabled or blocked by ISP firewalls.

How do I check if my SSH config file has syntax errors?

You can validate the configuration file without restarting the service by running sudo sshd -t. This command checks for syntax errors and reports them immediately. If it returns no output, the configuration is valid. If it reports errors, fix the indicated lines in /etc/ssh/sshd_config.

What if my VPN provider blocks port 22?

Some consumer-grade VPN providers block standard ports like 22 to prevent abuse or enforce their own paid SSH services. If you cannot connect even after verifying all server-side settings, try changing the SSH port to a non-standard number (like 2222) on the server and configure your client to connect to that port instead.

Can I use port forwarding to bypass this issue?

If direct SSH is blocked, you can create an SSH tunnel from a machine that has access to the VPS. However, if the VPS itself is unreachable via SSH, you need console access to set up port forwarding or alternative protocols. See Tunnel between machine and VPS with port forwarding for techniques on establishing secure tunnels when direct access is limited.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More