Created
August 12, 2016 16:45
-
-
Save vaelen/0dd849f2224d7be869815f263d20911b to your computer and use it in GitHub Desktop.
A bash script for routing connections through a gateway machine. You can create symlinks to this script named the same thing as the remote hostnames.
This file contains hidden or 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
#!/bin/bash | |
GW="vagrant@localhost" | |
GW_PORT=2222 | |
GW_NAME="gw" | |
HOST=${0##*/} | |
if [ "${HOST}" == "connect.sh" ] | |
then | |
HOST=$1 | |
fi | |
if [ -z "${HOST}" ] | |
then | |
echo "Please provide a host to connect to." | |
exit 1 | |
elif [ "${HOST}" == "${GW_NAME}" ] | |
then | |
ssh -A -t -X -p ${GW_PORT} ${GW} | |
else | |
ssh -A -t -X -p ${GW_PORT} ${GW} "/usr/bin/ssh -t -X -A ${HOST}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create symlinks to this script named the same thing as the remote hostnames that you want to connect to.