iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
An SSH tunnel can fail in three different ways: the SSH session can become stale, the forwarding socket can fail to open, or the tunnel can remain healthy while the service behind it is unreachable. A running ssh process proves only that a process exists; it does not prove that traffic can cross the forwarding path. Diagnose those layers separately, then use SSH server-alive checks, ExitOnForwardFailure=yes, and (when needed) autossh under a service supervisor.
What an SSH tunnel actually depends on
A tunnel is a long-lived SSH/TCP connection carrying one or more forwarding channels. The outer connection authenticates to the SSH server; each forwarding request then creates a path to another host and port. A failure in any layer can look like “the tunnel is up” from a process list.
Recommended Free Tools
- Local forwarding (
-L) opens a listener on the client. A connection to that local address is sent through SSH and then from the SSH server to the destination. - Remote forwarding (
-R) asks the SSH server to listen and send incoming connections through the SSH session to a destination reachable from the client side. - Dynamic forwarding (
-D) creates a SOCKS proxy; applications must be configured to use it, and DNS behavior depends on the application and proxy settings.
The SSH process, the forwarding listener, the route to the destination, and the destination service are separate failure points. Treating them as one “connection” is the source of most misleading troubleshooting.
Recognize the failure mode before changing settings
| What you observe | Most likely layer | What to verify |
|---|---|---|
The ssh process exited |
Authentication, network, host-key, option, or forwarding setup failure | Run in the foreground with -vvv and read the final exit message. |
| The process remains, but the local port is not listening | Local bind collision, permission problem, or an option that never established the requested forward | Check ss -ltnp locally and use ExitOnForwardFailure=yes. |
| The listener exists, but clients get connection refused or time out | Destination service, routing, firewall, DNS, or remote bind policy | Test the destination independently from the endpoint that should reach it. |
| Existing connections work, new ones hang after idle time | Stale NAT, firewall, or load-balancer state on the outer TCP session | Enable protocol-level server-alive checks and tune the interval to the network. |
| A reverse tunnel is up, but remote clients cannot reach it | Remote listener bound only to loopback, or server policy/firewall blocks the requested address | Inspect the listener on the SSH server and confirm its bind address. |
Diagnose a broken tunnel in a controlled sequence
- Reproduce it in the foreground. Stop the background copy and run a forwarding-only command with verbose logging. For a local database example:
ssh -vvv -N -o ExitOnForwardFailure=yes -L 127.0.0.1:15432:db.internal:5432 user@bastionThe
-Noption tells SSH not to run a remote command. The terminal remains attached so you can see authentication, channel creation, and disconnect messages. Look for a success message for every requested-L,-R, or-Dforward, not merely “Authentication succeeded.” - Make setup failures fatal.
ExitOnForwardFailure=yesmakes SSH terminate when it cannot establish a requested listening socket, such as when a port is already occupied or a bind is prohibited. Without it, you can be left with a shell or session that looks healthy while the requested forward was never created. - Inspect the expected listener. On the client, run
ss -ltnp(or the platform equivalent) and confirm that the exact address and port are listening. A listener on127.0.0.1is not the same as one on a LAN address. For a reverse forward, run the same check on the SSH server; the remote listener is not located on the client. - Test the application path independently. Use a protocol-aware client from the side that should access the service: a database client for a database, an HTTP client for HTTP, or the vendor’s native diagnostic tool. A raw TCP check can show that a port accepts connections but cannot prove that the application is healthy.
- Test the destination from the correct endpoint. With
-L, the destination host and port are reached from the SSH server, not from your laptop. With-R, the destination is reached from the SSH client. Verify DNS resolution, routes, firewall rules, and service state from that side. - Separate identity and transport errors. Check host-key verification, credentials, account restrictions, DNS for the bastion, and the path to TCP port 22 independently. Keepalive options cannot repair an expired key, a rejected login, a blocked SSH port, or a stopped destination service.
- Capture the first failure, not only the final symptom. In
-vvvoutput, note whether the failure happens before authentication, while requesting the forward, when opening a channel, or after an idle period. That timing determines which layer to fix.
Keep an established SSH session from going silently stale
ServerAliveInterval and ServerAliveCountMax
These are encrypted SSH protocol checks sent by the client. ServerAliveInterval sets the number of seconds between checks when no traffic has been received from the server. ServerAliveCountMax limits unanswered checks before SSH disconnects. The OpenSSH manual gives this concrete example: with ServerAliveInterval 15 and the default count of 3, an unresponsive server is disconnected after approximately 45 seconds.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
The settings create a deliberate detection policy rather than a guarantee of service availability. A shorter interval detects failure sooner and generates more traffic; a longer interval is quieter but leaves a dead path undiscovered for longer. Choose an interval below the shortest idle timeout imposed by a NAT, firewall, or load balancer, while allowing for expected outages and latency.
Host reporting-bastion
HostName bastion.example.net
User tunnel
ServerAliveInterval 15
ServerAliveCountMax 3
Put shared policy in ~/.ssh/config or supply it with -o options. Keep the values explicit for critical tunnels so a change in system or distribution defaults does not alter failure detection unexpectedly.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Why TCPKeepAlive is not the same thing
TCPKeepAlive uses the operating system’s TCP-level probes. OpenSSH documents this mechanism as slower to detect some failures and spoofable compared with encrypted-channel server-alive messages. It can still be useful for reclaiming half-open TCP sessions, but it should not be your only liveness policy when you need a predictable SSH-level timeout.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Neither kind of keepalive authenticates a destination application, opens a blocked firewall port, or repairs routing. They answer the question “does the SSH peer respond?” rather than “can my database, web service, or message broker complete a request?”
Make forwarding setup errors visible
Use -o ExitOnForwardFailure=yes while diagnosing and in unattended commands. It tells SSH to exit if a requested forward cannot bind or listen. Typical causes include another process already using the port, insufficient permission for a privileged port, a server refusing a remote forward, or a requested bind address that does not exist.
ssh -N
-o ServerAliveInterval=15
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-L 127.0.0.1:15432:db.internal:5432
user@bastion
This option validates establishment of the forwarding socket only. For a local forward, SSH can successfully bind 127.0.0.1:15432 even when db.internal:5432 is down; the destination connection is opened later when an application connects. Continue to test the application path after SSH reports a successful setup.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Use autossh when the tunnel must recover itself
autossh starts an SSH process, monitors it, and restarts it when it dies or stops passing traffic. It is useful on laptops, gateways, and small servers where a tunnel should recover from an interrupted network without manual intervention. It does not replace correct SSH options, authentication, firewall rules, or destination health checks.
autossh -M 0 -N
-o ServerAliveInterval=15
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-L 127.0.0.1:15432:db.internal:5432
user@bastion
-M 0 disables autossh’s separate monitor port. In this pattern, the SSH protocol checks make an unresponsive peer cause SSH to exit; autossh then restarts it. The autossh manual recommends combining monitoring with ExitOnForwardFailure=yes so a failed forwarding setup is not mistaken for a healthy session.
Requirements for reliable autossh operation
- Unattended authentication: use a protected key, an agent, or another non-interactive method that complies with your security policy. A process that is waiting for a password cannot recover automatically.
- Stable configuration: specify the identity file, host alias, forwarding options, and keepalive policy explicitly. Test the exact command manually before daemonizing it.
- Bounded failure behavior: retain
ExitOnForwardFailure=yesso port collisions and rejected forwards trigger a restart or a visible failure instead of a false-green process. - Logs: preserve SSH’s original diagnostic output. Repeated restarts without the first SSH error can hide a permanent configuration problem.
If the destination service is down, autossh will normally keep the SSH session available because the forward itself can still be established. Add an application-level health check if you need to alert on destination failure rather than merely on tunnel failure.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Run important tunnels under a service supervisor
For boot-time or production use, place SSH or autossh under systemd, launchd, supervisord, or the equivalent supervisor on your platform. Supervision supplies startup ordering, restart limits, centralized logs, and a clear owner for the process. This is an operational design choice; no single supervisor is required by OpenSSH.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchA minimal systemd unit for autossh might look like this:
[Unit]
Description=Database SSH tunnel
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=tunnel
ExecStart=/usr/bin/autossh -M 0 -N
-o ServerAliveInterval=15
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-L 127.0.0.1:15432:db.internal:5432 user@bastion
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Adjust the executable path, account, key configuration, and host name for your system. After installing the unit, use your platform’s service commands to reload configuration, enable it at boot, start it, and inspect its journal. Set a restart limit or back-off policy appropriate to your environment so a permanent authentication or bind error does not create an uncontrolled restart loop.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Check listener scope, firewalls, and routing
Local forwarding exposure
Bind local forwards to loopback unless another machine genuinely needs to use them. 127.0.0.1:15432 limits access to the local host; binding to a LAN address exposes the forwarded service to every network path allowed by the host firewall and any upstream controls. A tunnel that “works” only after changing to a wildcard bind may have become an unintended access path.
Remote forwarding exposure
OpenSSH documents loopback as the default bind scope for remote listening sockets. Consequently, a reverse forward may be reachable from the SSH server itself but not from other hosts. If remote clients must connect, request an appropriate non-loopback bind and confirm that the SSH server permits it, then review host firewall rules and access controls. Expanding the bind address is a security change, not merely a connectivity tweak.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Routing direction matters
For -L local_port:destination_host:destination_port, the SSH server resolves and connects to destination_host. For -R remote_port:destination_host:destination_port, the SSH client side makes that destination connection. A successful DNS lookup or route on your workstation therefore says nothing about the route available from the opposite endpoint.
Choose the simplest durable pattern
| Pattern | Strength | Trade-off | Best fit |
|---|---|---|---|
| Plain SSH with server-alive checks | Fewest moving parts and straightforward logs | Needs a separate supervisor or manual restart after exit | Interactive work and simple, manually managed tunnels |
autossh with bounded keepalives |
Restarts SSH when it exits or monitoring detects a failure | Requires unattended authentication and careful startup-error handling | Long-lived user or host tunnels that should self-recover |
| Supervisor around SSH or autossh | Boot integration, dependencies, restart limits, and centralized logs | More configuration and another layer to operate | Production, gateways, and critical boot-time connectivity |
| Loopback-only listener | Minimizes network exposure | Remote clients cannot use the forward directly | Local development and administrative access |
| Non-loopback listener | Allows selected remote clients to connect | Requires deliberate firewall and authorization review | Shared access where the exposure is explicitly designed |
Common “fixes” that do not fix the real problem
- Leaving SSH running in the background: backgrounding only hides output; it does not keep a dead TCP path alive.
- Increasing keepalive frequency indefinitely: frequent probes cannot overcome a blocked route or a stopped application and may create unnecessary traffic.
- Assuming a listening local port proves the destination works: local forwarding is often lazy; the destination connection is attempted only when a client opens the local port.
- Disabling host-key verification: this removes an important authentication control and does not solve forwarding, routing, or liveness failures.
- Binding to all interfaces as a test and forgetting to revert it: the tunnel may become reachable by unintended hosts. Return to loopback or apply a narrowly scoped firewall rule.
- Adding autossh before fixing the command: autossh can restart a permanently invalid command forever. First make the foreground
ssh -vvv -Ninvocation succeed with explicit forwarding checks.
A practical recovery checklist
- Run the exact tunnel in the foreground with
-vvv,-N, andExitOnForwardFailure=yes. - Confirm authentication, host-key verification, and the bastion’s TCP reachability.
- Confirm every requested listener with
ss -ltnpon the endpoint where it should exist. - Check the destination service from the endpoint that SSH uses to reach it.
- Verify DNS, routes, and firewall policy in that direction.
- Add
ServerAliveInterval 15andServerAliveCountMax 3as a deliberate starting policy; the documented example detects an unresponsive peer in approximately 45 seconds. - Use
autossh -M 0when automatic restart is required and unattended authentication is ready. - Put critical tunnels under a service supervisor with dependencies, restart back-off, and retained logs.
- Keep listeners on loopback unless remote access is required and explicitly authorized.
What “healthy” should mean in monitoring
Monitor more than the process ID. A useful check has at least three signals: the supervisor reports the process as running, the expected listener is bound to the intended address, and a protocol-aware probe can complete a request through the tunnel. Alert separately when the SSH session is down, when forwarding setup fails, and when the ultimate service is unreachable. This separation prevents an apparently green SSH process from masking an application outage.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

