Skip to content

Developers, system administrators and a growing number of curious home users meet the same question sooner or later: do I need a VPN to reach my server, or is an SSH tunnel enough? Both encrypt a path across an untrusted network, and both are described with the word tunnel. Yet they sit at different layers, cover different traffic and suit different jobs. Mixing them up leads either to a setup that is more complicated than needed, or to a false sense that everything is protected when only one application is.

This article compares a VPN and an SSH tunnel as ways to get secure remote access. It explains how each works in plain terms, shows the three main kinds of SSH forwarding, lines the two up in a table, and gives a rule for choosing. It assumes you want to reach systems you own or are authorised to use. If you only need a refresher on the basic idea of a tunnel first, our article on what a VPN tunnel is is a short read.

What an SSH tunnel actually is

SSH, short for Secure Shell, is a protocol for logging in to a remote machine and running commands over an encrypted connection. A less obvious feature is that the same encrypted connection can carry other traffic. When you use it that way, people call it an SSH tunnel or port forwarding.

The idea is simple. You open one SSH connection to a server you can log in to. Inside that connection you ask SSH to carry traffic for some other port or program. To the network in the middle, everything looks like one encrypted SSH session. It cannot read what is inside, and it cannot tell that you are reaching a database or a web page behind the server.

Three forwarding styles cover most uses.

Local forwarding. You choose a port on your own machine, for example 5433, and a target as seen from the server, for example a database on the server's private address. When your application connects to your own machine on port 5433, SSH carries the connection through the tunnel and the server connects to the database on your behalf. This is the classic way to reach an admin interface or database that must not face the internet.

Remote forwarding. The direction is reversed. You ask the server to listen on a port and send whatever arrives back to a service on your machine. It is used to let a remote machine reach something local, for example for a demonstration, and it needs careful limits because it opens a door into your machine.

Dynamic forwarding. SSH acts as a SOCKS proxy on your own machine. Applications that are set to use that proxy send all their connections through the tunnel, and the server makes the connections for them. This is the form that comes closest to a VPN, but only for programs that you have configured to use it.

A fourth, related feature is the jump option, where you reach an internal machine by passing through a gateway server in one command. It does not create a general tunnel, but it is how many administrators avoid exposing internal machines directly.

None of these forms creates a new network interface on your computer. They are tools to forward chosen connections. That is the main difference from a VPN.

What a VPN does differently

A VPN, in the sense used here, creates a virtual network interface on your device. The operating system sends traffic into that interface according to its routing table, and the VPN software encrypts it and carries it to the VPN server. Applications do not need to know. A browser, a mail client, a chat tool and a background updater all go through the same path unless you set exceptions.

That makes a VPN different in four practical ways.

  • It covers the whole device by default. You do not configure each application.
  • It works at the network level, so it can carry many protocols, including those that SSH forwarding handles badly, such as traffic that uses UDP.
  • It can join your device to a private network, so internal names and addresses resolve as if you were in the office.
  • It is built for many users. Accounts, keys and policies can be handled for a whole team.

On the other hand, a VPN needs a server and software on both ends. If you only want to reach one internal web page on a machine you already administer by SSH, that may be more machinery than the job needs. For a general explanation of the technology, see the Cloudflare overview of a VPN.

Side-by-side comparison

Question SSH tunnel VPN
Layer it works at Application connection (TCP forwarding) Network layer (virtual interface)
What it covers Only the ports or apps you forward The whole device unless you set exceptions
Needs software on the server An SSH server, which you probably already run A VPN server and configuration
Needs software on your device The standard SSH client A VPN client or app
Typical use One service on one server, quick admin access Daily protection and private network access
Handles UDP and other protocols Poorly or not at all with plain forwarding Yes, in normal VPN designs
Multiple users Manual: keys and accounts per person Built for it with central accounts
DNS lookups Only covered if the app sends them through the proxy Usually covered, but check for leaks
Hides your traffic from the local network For forwarded connections only For all routed traffic
Effort for a one-off task Very low Medium to high
Effort for a team High to keep tidy Lower once built

The table makes the shape of the choice clear. If you are doing one thing quickly, SSH forwarding is light and precise. If you need ongoing protection or a whole network, a VPN is the sturdier tool.

When an SSH tunnel is the better fit

An SSH tunnel is a good answer in several everyday cases.

  1. Reaching a database or admin panel on a server you manage. The service listens only on the server's local address. You forward a port, work, and close the connection. Nothing is opened to the internet.
  2. A one-off task on a trusted server. There is no need to install a VPN for a five-minute job.
  3. A developer testing a service on a remote machine. Forwarding a port lets the local browser talk to a development service.
  4. Reaching an internal machine through a gateway. With a jump option, you can reach a machine that is not directly reachable without opening more services.
  5. A small, technical team that already uses SSH keys. The overhead is low and everyone knows the tool.

Even in these cases, treat the tunnel as an administrative tool, not a general privacy tool. The server you log in to can see all the traffic that leaves it. You are trusting that server and whoever runs it.

When a VPN is the better fit

A VPN is stronger when the need is broader or continuous.

  1. Protection on shared Wi-Fi. On a hotel or cafe network, you want all apps covered, not only the ones you remembered to configure. See how a VPN protects you on public Wi-Fi for the basics.
  2. A remote worker who uses many internal tools. File shares, internal websites, printers and chat all work as if on the office network.
  3. Non-technical users. Staff should not have to understand forwarding flags. A VPN app with a single connect button is simpler to support.
  4. Applications that do not support proxies. Many programs cannot be pointed at a SOCKS proxy at all. A VPN covers them without changes.
  5. A team that needs central control. Revoking one person's access should not require editing keys on every server.

For a person who only wants a private path on public networks, a VPN service for individuals is the straightforward option. A different decision, between building your own VPN server and buying a service, is discussed in self-hosted VPN vs commercial VPN. The newer WireGuard design, described on its official site, has made self-hosted VPNs much simpler to run than they used to be.

Using the two together

The two tools are not rivals. Many administrators use both, each for its own job.

  • A VPN gets the laptop onto a private network safely. Inside that network, SSH (with or without forwarding) is used to reach individual servers.
  • A jump host sits in the private network. The administrator connects to the VPN, then uses SSH with the jump option to reach machines that accept connections only from the jump host.
  • On a public network, a VPN app protects the whole device, while SSH forwarding reaches the one database that must never be exposed.

Stacking them does not make traffic more secure in a magical way, because each layer protects a different portion. But it does limit the damage if one layer is weak: a stolen SSH key, for example, is far less useful if the server it unlocks is reachable only from inside a VPN that also needs a second factor.

Good habits for either approach

For SSH tunnels

  • Use key-based login protected with a passphrase, and turn off password login on the server where policy allows.
  • Add a second factor where possible. CISA's multi-factor authentication guidance explains the options.
  • Bind forwarded ports to the local address only, so other machines on your network cannot use your tunnel.
  • Close tunnels when you finish. A forgotten one is an open door.
  • Check the server's host key fingerprint the first time you connect. A warning when it changes deserves attention, not a click-through.
  • Restrict forwarding in the server configuration if users do not need it.

For VPNs

  • Keep the VPN server and client updated.
  • Give each person their own credentials.
  • Test for leaks after setup. How to test a VPN lists the checks.
  • Use split tunneling only when you know exactly what it leaves outside.
  • Follow your employer's rules for remote access, which are the kind of thing NIST's telework guidance describes in detail.

Three scenarios

The developer checking a staging database. Aroon needs to look at a database that listens only on a server's internal address. She uses local forwarding for the afternoon, works through her usual client and closes the tunnel at the end. No new software, nothing exposed. A VPN would work, but it would take longer to set up than the job itself.

The consultant on conference Wi-Fi. Daniel is at a conference with open Wi-Fi. He needs email, a shared drive and a few client web tools. An SSH tunnel would cover only one application at a time. He uses a VPN app on his laptop instead so that every program is covered, and he uses SSH only to reach a single customer server when required.

The home lab hobbyist. Mei runs a small server at home with a media library and a few services. For one-off checks she uses SSH forwarding. Because family members also want to reach the files from outside, she sets up a VPN that gives each person a profile. Her own SSH keys stay for administration only.

Mistakes to avoid

  • Treating a dynamic tunnel as a full VPN. If one app is not configured for the proxy, it goes out normally. DNS may do the same.
  • Forgetting that the server sees your traffic. An SSH tunnel moves trust to the server's operator; it does not remove it.
  • Leaving forwards open. Convenience tunnels left running overnight are a common finding in security reviews.
  • Using forwarding to dodge a network policy. An organisation may forbid it for good reasons. Follow the rules of the network you use, and use tunnels only to reach systems you are allowed to use.
  • Sharing one key among many people. You cannot tell who did what, and revoking access is painful.
  • Expecting either tool to protect the device. Neither stops malware, phishing or a weak password. See what a VPN cannot protect you from.

Summary

An SSH tunnel carries chosen connections through one encrypted session to a server you can log in to. It is light, precise and excellent for administration, but it covers only what you forward and shifts trust to the server. A VPN creates a virtual network interface that carries the whole device's traffic and can join it to a private network, which suits daily protection, many users and non-technical staff. Many careful setups use both: a VPN to get onto the network, SSH to reach individual systems, with keys, second factors and logging around them.

If your need is protection on shared networks across all your apps, you can look at the pricing page to see how a prepaid pass would fit.

Frequently asked questions

Is an SSH tunnel the same as a VPN?

No. An SSH tunnel carries traffic for chosen ports or applications through one encrypted connection to a server you can log in to. A VPN creates a virtual network interface and normally carries all the traffic of the device, whichever application sends it.

Can an SSH tunnel replace a VPN for everyday browsing?

Only partly. A dynamic SSH tunnel acts as a SOCKS proxy for applications that are set to use it, but anything not configured, including some background apps and DNS lookups, may still go out directly. A VPN app covers the whole device more consistently.

Which is easier to set up for a single server?

For reaching one service on one server you administer, an SSH tunnel is usually quicker because you already have SSH access and need no extra software on the server. A VPN pays off when many services, many machines or many users are involved.

Is SSH port forwarding a security risk?

It can be, if it is allowed everywhere without control. Forwarding can carry traffic around firewall rules that the organisation intended. Administrators often restrict it in the server configuration, and employees should follow the policy of the network they use.

Does an SSH tunnel hide my traffic from the website?

No. The website still sees a connection coming from the SSH server's address, and the server operator can see where your traffic goes. The tunnel protects the path between you and the server, nothing more.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Need a VPN for a short trip or a busy month?

XPASS sells prepaid passes for a set number of days. You pay once and nothing renews automatically.

See passes

Keep reading

VPN Basics

What Is a VPN Tunnel? A Simple Explanation

A VPN tunnel is not a place but a method: your data is wrapped inside other data and carried to the VPN server. See the anatomy, the life cycle and the limits.

9 min read

VPN Basics

VPN vs Proxy: What Is the Difference?

Both a VPN and a proxy sit between you and a website, but they differ in scope, encryption and trust. Here is a clear comparison, including Chrome proxy settings vs a system VPN.

9 min read

VPN Security

VPN Port Forwarding Explained: Uses and Risks

Port forwarding lets outside connections reach a device on a private network. This guide explains how it works with and without a VPN, what it is used for and what an open port can put at risk.

9 min read

Buying Guides

Self-Hosted VPN vs Commercial VPN

A home server and a commercial service solve different problems. Compare a Raspberry Pi or NAS VPN with a ready-made one, including CGNAT, upkeep and security.

9 min read

VPN Security

Zero Trust vs VPN: How They Differ

Zero trust and VPN are often presented as rivals, but they answer different questions. Here is how ZTNA, SASE and SD-WAN relate to a VPN, and when each one makes sense.

9 min read