Skip to content

Instantly share code, notes, and snippets.

@royvandam
Created February 28, 2020 10:40
Show Gist options
  • Save royvandam/f7b08d9b6fcf84cd80644f2c7d5e192b to your computer and use it in GitHub Desktop.
Save royvandam/f7b08d9b6fcf84cd80644f2c7d5e192b to your computer and use it in GitHub Desktop.
Auto-starting reverse SSH proxy using systemd service file
[Unit]
AssertPathExists=/home/${user}/.ssh/id_rsa
After=network.target
[Service]
User=${user}
WorkingDirectory=/
ExecStart=/usr/bin/ssh -vvv -N -T \
-R 0:localhost:22 \
-o PasswordAuthentication=no \
-o IdentityFile=/home/${user}/.ssh/id_rsa \
-o TCPKeepAlive=yes \
-o ServerAliveInterval=300 \
-o ServerAliveCountMax=2 \
${user}@${host}
Restart=always
RestartSec=30
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment