Skip to content

Instantly share code, notes, and snippets.

@kevydotvinu
Last active July 11, 2019 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevydotvinu/32df9b964cef8e5f06deb6dc8b0a5509 to your computer and use it in GitHub Desktop.
Save kevydotvinu/32df9b964cef8e5f06deb6dc8b0a5509 to your computer and use it in GitHub Desktop.
[Unit]
Description=Setup a secure tunnel to %I
After=network-online.target
[Service]
User=kevy
EnvironmentFile=/etc/default/ssht@%i
ExecStart=/usr/bin/ssh -i /key.pem -NT -o ForwardX11=yes -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R ${REMOTE_PORT}:127.0.0.1:${LOCAL_PORT} ubuntu@${TARGET}
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
TARGET=<Instance IP>
LOCAL_PORT=22
REMOTE_PORT=2222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment