Skip to content

Instantly share code, notes, and snippets.

@agea
Created February 14, 2015 14:33
Show Gist options
  • Save agea/0631f630bbc3e24f725f to your computer and use it in GitHub Desktop.
Save agea/0631f630bbc3e24f725f to your computer and use it in GitHub Desktop.
reverse ssh persistent tunnel
#!/bin/bash
set +e
SSH_OPTIONS=" -i /home/pi/.ssh/id_rsa"
# Always assume initial connection will be successful
#export AUTOSSH_GATETIME=0
# Disable echo service, relying on SSH exiting itself
export AUTOSSH_PORT=0
#to test, use (check out man ssh for explanation of options:
#autossh -vv -- $SSH_OPTIONS -o 'ControlPath none' -R 31416:localhost:22 pi@agea.noip.me -N
#once proven, use (and rem out previous command):
autossh -f -- $SSH_OPTIONS -o 'ControlPath none' -g -R 0.0.0.0:31416:localhost:22 pi@168.235.66.155 -N 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment