Skip to content

Instantly share code, notes, and snippets.

@uchm4n
Created January 9, 2018 14:32
Show Gist options
  • Select an option

  • Save uchm4n/86ba74ed82b2658cbbd26590a1bdd57b to your computer and use it in GitHub Desktop.

Select an option

Save uchm4n/86ba74ed82b2658cbbd26590a1bdd57b to your computer and use it in GitHub Desktop.

Revisions

  1. uchm4n created this gist Jan 9, 2018.
    20 changes: 20 additions & 0 deletions reverse-ssh-tunnel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # 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