Dev.to Security 🔐 Cybersecurity 👁 2 📖 1 min read

Choosing a VPN or an SSH tunnel for remote database access

When a developer needs to reach a database that lives on a private network, two tools come up first: an SSH tunnel and a VPN. They solve overlapping problems, but they fit different situations. SSH tunnel: one

When a developer needs to reach a database that lives on a private network, two tools come up first: an SSH tunnel and a VPN. They solve overlapping problems, but they fit different situations.

SSH tunnel: one port, one purpose

An SSH tunnel forwards a single local port to a remote host through an encrypted connection. It needs only an SSH server you already have, takes one command, and exposes nothing else on the network. This is a good fit for occasional access to one database or one admin panel.

VPN: the whole network

A VPN places your machine inside the remote network, so every internal address becomes reachable. That helps when a team uses many internal services, or when tools cannot be pointed at a forwarded port. The trade-off is more setup, broader access to manage, and routing changes on the laptop.

A simple rule

  • One service, short session: use an SSH tunnel.
  • Many services, whole team, long sessions: use a VPN.
  • Public Wi-Fi with no private network involved: a consumer VPN encrypts traffic, but it does not replace either option above.

Keep keys out of shared folders, rotate them when people leave, and close tunnels you are not using.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.