Skip to content

Instantly share code, notes, and snippets.

@ErickAgrazal
Last active June 3, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErickAgrazal/15f6f12528328601b8e8b31e29211576 to your computer and use it in GitHub Desktop.
Save ErickAgrazal/15f6f12528328601b8e8b31e29211576 to your computer and use it in GitHub Desktop.
A script that creates a tunnel to connect to a server through a bastion as a proxy.
#####################################
# Script variables ##################
#####################################
IDENTITY_FILE="~/.ssh/id_rsa"
SERVER=
SERVER_PORT=1433
PROXY_BASTION_USER=
PROXY_BASTION_SERVER=
LOCAL_PORT=14333
SSH_OPTIONS="StrictHostKeyChecking no"
#####################################
# Script logic ######################
#####################################
echo "ssh -i $IDENTITY_FILE -o \"${SSH_OPTIONS}\" -4 -f -N -L ${LOCAL_PORT}:${SERVER}:${SERVER_PORT} ${PROXY_BASTION_USER}@${PROXY_BASTION_SERVER} sleep 10"
ssh -i $IDENTITY_FILE -o "${SSH_OPTIONS}" -4 -f -N -L ${LOCAL_PORT}:${SERVER}:${SERVER_PORT} ${PROXY_BASTION_USER}@${PROXY_BASTION_SERVER} sleep 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment