Skip to content

Instantly share code, notes, and snippets.

@vshmoylov
Created May 17, 2023 18:04
Show Gist options
  • Save vshmoylov/444b919f1a28c838195642df513dd5b2 to your computer and use it in GitHub Desktop.
Save vshmoylov/444b919f1a28c838195642df513dd5b2 to your computer and use it in GitHub Desktop.
ssh tunnel as systemd service
[Unit]
Description=Persistent SSH Tunnel from port XXXX on this server, docker ip to port localhost:YYYY on example.com server (local port forwarding)
After=network.target
[Service]
Restart=on-failure
RestartSec=5
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -L 172.17.0.1:XXXX:127.0.0.1:YYYY example.com
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment