Skip to content

Instantly share code, notes, and snippets.

@uchm4n
Created January 9, 2018 14:32
Show Gist options
  • Save uchm4n/86ba74ed82b2658cbbd26590a1bdd57b to your computer and use it in GitHub Desktop.
Save uchm4n/86ba74ed82b2658cbbd26590a1bdd57b to your computer and use it in GitHub Desktop.
Setup Service on Ubuntu to make reverse ssh tunnel on remote server
# Ubuntu 15.04+
[Unit]
Description=Setup a secure tunnel to server
Wants=network-online.target
After=network-online.target
[Service]
User=admin
Environment="LOCAL_ADDR=localhost"
ExecStart=/usr/bin/autossh -M 0 -N -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -R *:19871:localhost:22 root@server -p 22 -X
RestartSec=60
Restart=always
[Install]
WantedBy=multi-user.target
# After that you can enter in remote server and execute folowing: ssh root@localhost -p 19871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment