Skip to content

Instantly share code, notes, and snippets.

@mikeymckay
Created November 3, 2009 14:07
Show Gist options
  • Save mikeymckay/225069 to your computer and use it in GitHub Desktop.
Save mikeymckay/225069 to your computer and use it in GitHub Desktop.
#!/bin/sh
# ------------------------------
# Added by tarlac_install script
# ------------------------------
# See autossh and google for reverse ssh tunnels to see how this works
# When this script runs it will allow you to ssh into this machine even if it is behind a firewall or has a NAT'd IP address.
# From any ssh capable machine you just type ssh -p $PORT_MIDDLEMAN_WILL_LISTEN_ON localusername@middleman
# This is the username on your local server who has public key authentication setup at the middleman
USER_TO_SSH_IN_AS=chits
# This is the username and hostname/IP address for the middleman (internet accessible server)
MIDDLEMAN_SERVER_AND_USERNAME=chitstunnel@lakota.vdomck.org
# Port that the middleman will listen on (use this value as the -p argument when sshing)
PORT_MIDDLEMAN_WILL_LISTEN_ON=11829
# Connection monitoring port, don't need to know this one
AUTOSSH_PORT=27554
# Ensures that autossh keeps trying to connect
AUTOSSH_GATETIME=0
su -c "autossh -f -N -R *:${PORT_MIDDLEMAN_WILL_LISTEN_ON}:localhost:22 ${MIDDLEMAN_SERVER_AND_USERNAME} -oLogLevel=error -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no" $USER_TO_SSH_IN_AS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment