Skip to content

Instantly share code, notes, and snippets.

@nemik
Created November 18, 2022 15:36
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 nemik/f1746fdff66511e1e153a2ba4be16c66 to your computer and use it in GitHub Desktop.
Save nemik/f1746fdff66511e1e153a2ba4be16c66 to your computer and use it in GitHub Desktop.
SSH Tunnel service
Host myserver.net
User admin
HostName myserver.net
Host tunneled_server
#UserKnownHostsFile /dev/null
#StrictHostKeyChecking no
ForwardAgent yes
HostName localhost
Port 9001
ProxyJump myserver.net
User someuser
LocalForward 0.0.0.0:8888 0.0.0.0:8888
LocalForward 0.0.0.0:8080 0.0.0.0:8080
[Unit]
Description=Setup a secure tunnel to nemik.net
After=network.target
[Service]
User=someuser
Group=someuser
WorkingDirectory=/home/someuser
ExecStart=/bin/bash tunnel.sh
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
#!/bin/bash
/usr/bin/ssh -NT -i /home/someuser/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 9001:localhost:22 someuser@myserver.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment