Created
January 9, 2018 14:32
-
-
Save uchm4n/86ba74ed82b2658cbbd26590a1bdd57b to your computer and use it in GitHub Desktop.
Setup Service on Ubuntu to make reverse ssh tunnel on remote server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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