Reaching a Home Lab from a Locked-Down Work Laptop with Pure OpenSSH
The default answers for reaching a home server behind ISP NAT are Tailscale or
Cloudflare Tunnel (cloudflared). Both are great—until you hit a common set of
constraints:
- Home LAN (behind NAT): An always-on Raspberry Pi (
pi) and a Mac mini (mini). - Tiny public VPS (
vps): Too small for extra VPN daemons, and also a personal dev box that pushes to personal GitHub repos. - Locked-down work laptop (
corp-laptop): Cannot install VPN clients, outbound SSH is allowed, corporate keys live dynamically in$SSH_AUTH_SOCK, and corporate keys must never be offered or forwarded to the VPS or the internet.
Plain OpenSSH solves all of it with a few megabytes of RAM, end-to-end encryption, zero third-party control planes, and strict separation between corporate and personal keys. Both server setup scripts—setup-tunnel.sh and persist-tunnel.sh —are hosted right alongside this note; for a zero-key browser-only alternative that needs no VPS and no outbound SSH, see the companion Cloudflare Tunnel browser SSH setup.
Why Pure OpenSSH?
| Criterion | Pure OpenSSH (Reverse Tunnel + ProxyJump) |
Tailscale | Cloudflare Tunnel (Browser SSH) |
|---|---|---|---|
| Corp laptop | Outbound SSH + encrypted personal key | Blocked (VPN client) | Browser only (HTTPS/443); zero keys |
| Extra software | None (sshd + systemd) |
Daemon on every node | cloudflared + domain + Zero Trust |
| Trust boundary | End-to-end (corp-laptop → target) |
End-to-end WireGuard | CF Edge decrypts browser I/O & signs CA |
| VPS RAM footprint | ~few MB | ~30–60+ MB | N/A (runs on pi) |
| Capabilities | Full ssh, scp, rsync, -L/-D |
Built-in (full L3) | Interactive xterm.js shell only |
Tailscale is still great for mobile devices (e.g., viewing a Pi webcam from a
phone), and Cloudflare Tunnel is a strong fallback when you want zero personal
keys on corp-laptop. Keeping OpenSSH for daily laptop access gives you native
terminal ergonomics and full port forwarding without ever putting the VPS on
your tailnet.
Architecture
corp-laptop --(SSH #1)--> vps <--(reverse tunnel :2222)-- pi --(LAN :22)--> mini
| ^ ^
+----------------(SSH #2, end-to-end)----------------+ |
+----------------(SSH #3, end-to-end)-----------------------------------+
- Persistent reverse tunnel (
pi→vps):pidials out tovpsand binds its SSH port strictly to loopback (127.0.0.1:2222) under a locked-down/bin/falseuser—nothing new is exposed publicly. - Chained
ProxyJump(corp-laptop→vps→pi→mini): Every hop authenticates end-to-end fromcorp-laptop. No personal private keys live onvpsorpi, andForwardAgentstays off for both. - Isolated personal
ssh-agent(~/.ssh/agent.sock): OpenSSH cannot filter dynamically loaded corporate keys per host inside a shared agent. A dedicated, unexported personal socket leaves$SSH_AUTH_SOCKuntouched while safely enablingForwardAgent ~/.ssh/agent.socktovpsfor personal GitHub pushes.
1. Reverse Tunnel (pi → vps)
Both scripts assume Debian 12+ or Ubuntu 22.04+. First, generate a dedicated
passphrase-free ed25519 key on pi solely for unattended tunnel reconnects:
ssh-keygen -t ed25519 -N "" -C "pi-reverse-tunnel" -f ~/.ssh/id_ed25519_vps_tunnel
On vps, fetch and run setup-tunnel.sh
with the Pi’s public
key (either as a file argument or piped on stdin):
curl -fLO https://joyus.org/2026/lightweight-ssh-homelab/setup-tunnel.sh
chmod +x setup-tunnel.sh
cat id_ed25519_vps_tunnel.pub | sudo ./setup-tunnel.sh
It creates a /bin/false tunnel user, installs a scoped Match User tunnel
drop-in at /etc/ssh/sshd_config.d/99-reverse-tunnel-tunnel.conf, validates
with sshd -t (rolling back on error), reloads sshd, and verifies the
effective config via sshd -T -C user=tunnel. A few details matter:
AllowTcpForwarding remote,GatewayPorts no, andPermitListen localhost:* 127.0.0.1:* [::1]:*restrict forwards strictly to loopback.localhost:*is required because OpenSSH sendslocalhoston the wire for-R 2222:127.0.0.1:22; allowing only127.0.0.1:*rejects it.ClientAliveInterval 30/ClientAliveCountMax 3scoped insideMatch User tunnelclears stale tunnels within ~90s after ISP drops without affecting normal sessions.- Keep
AllowTcpForwarding yes(the default) for your normal users onvpsandpisoProxyJump(ssh -W) works.
On pi, skip autossh and let systemd + OpenSSH handle reconnects via
persist-tunnel.sh
, which auto-detects pi’s local sshd
port and installs reverse-ssh-tunnel.service:
curl -fLO https://joyus.org/2026/lightweight-ssh-homelab/persist-tunnel.sh
chmod +x persist-tunnel.sh
sudo ./persist-tunnel.sh <VPS_IP> 2222
Verify on vps that port 2222 is listening on loopback only:
ss -tln | grep ':2222\b'
# Expected: LISTEN ... 127.0.0.1:2222 0.0.0.0:*
The critical unit options in reverse-ssh-tunnel.service:
-F /dev/null+IdentitiesOnly=yes+IdentityFile=...isolate the daemon from your personal~/.ssh/config.ExitOnForwardFailure=yesforces an immediate exit (and 10ssystemdretry) ifvpsbriefly still holds port2222from a dead connection.StartLimitIntervalSec=0preventssystemdfrom giving up during multi-hour ISP outages, andBatchMode=yes+StrictHostKeyChecking=accept-newavoids interactive hangs while pinning the VPS host key on first connect.
2. Isolated ssh-agent and ~/.ssh/config
On corp-laptop, never overwrite global $SSH_AUTH_SOCK. Instead, start a
dedicated personal agent at ~/.ssh/agent.sock in your shell rc without
exporting it (see __setup_ssh_agent in
zsh/zshrc
and
bash/bashrc
).
There is no passphrase prompt on terminal startup—OpenSSH unlocks the key lazily
on first use via AddKeysToAgent, and modern ed25519 private keys embed their
public key unencrypted so no sibling .pub file is needed.
Then adapt
config.sample
into ~/.ssh/config (chmod 600 ~/.ssh/config): Host vps sets
ForwardAgent ~/.ssh/agent.sock; Host pi targets 127.0.0.1:2222 via
ProxyJump vps with HostKeyAlias pi; Host mini sets ProxyJump pi; a
shared Host vps pi mini github.com block pins
IdentityAgent ~/.ssh/agent.sock, IdentityFile ~/.ssh/%u.key,
IdentitiesOnly yes, and AddKeysToAgent 10h; and corporate hosts sit above
Host *.
Three Subtle OpenSSH Gotchas
- Never pass
-A(ssh -A vps): CLI flags override~/.ssh/config.-AsetsForwardAgent yes, dropping~/.ssh/agent.sockand silently forwarding your corporate$SSH_AUTH_SOCK. - Use
HostKeyAlias pifor tunneled targets: Avoids[127.0.0.1]:2222collisions in~/.ssh/known_hostswith other port forwards. - Never put corporate
IdentityFilelines inHost *: UnlikeIdentityAgentorForwardAgent(first-match-wins),IdentityFileaccumulates across every matching block.
3. Day-to-Day Usage
Once wired up, every host and tunnel is one command from corp-laptop:
ssh vps # Dev session (personal GitHub via isolated agent)
ssh pi # corp-laptop -> vps -> pi
ssh mini # corp-laptop -> vps -> pi -> mini
ssh -N -L 5900:localhost:5900 mini # Mac mini Screen Sharing -> vnc://localhost:5900
ssh -D 1080 pi # Ad-hoc SOCKS5 proxy into home LAN
Sometimes the boring tool sitting in /usr/bin/ssh for 25 years is still the
cleanest one for the job.