Last active
June 3, 2020 16:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################### | |
# 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