Skip to content

Instantly share code, notes, and snippets.

@c9s
Created July 30, 2013 10:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/6111795 to your computer and use it in GitHub Desktop.
Save c9s/6111795 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Example script to start up tunnel with autossh.
#
# This script will tunnel 12345 from the remote host
# to 12345 on the local host.
#
ID=login_here
HOST=destination.host.com
if [ "X$SSH_AUTH_SOCK" = "X" ]; then
eval `ssh-agent -s`
ssh-add $HOME/.ssh/id_rsa
fi
AUTOSSH_POLL=600
AUTOSSH_PORT=20000
AUTOSSH_GATETIME=30
AUTOSSH_LOGFILE=$HOST.log
AUTOSSH_DEBUG=yes
AUTOSSH_PATH=/usr/bin/ssh
export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT
autossh -2 -fN -M 20000 -L 12345:localhost:12345 ${ID}@${HOST}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment