Created
June 29, 2018 11:24
-
-
Save sebge2emasphere/ea4f474c14c6f7a98a06fc55d9224520 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
function usage() | |
{ | |
echo "Open a proxy SSH on Amazon VPC." | |
echo "" | |
echo "./open-proxy.sh" | |
echo -e "\t--help" | |
echo -e "\t--envName=[dev/test/preprod/prod]" | |
echo "" | |
} | |
ENV_NAME="" | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
--help) | |
usage | |
exit | |
;; | |
--envName) | |
ENV_NAME="$2" | |
shift | |
shift | |
;; | |
*) | |
usage | |
exit | |
;; | |
esac | |
done | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
source $DIR/../hbase-env.sh "$ENV_NAME" | |
ssh-add -k ~/.ssh/bastion-$ENV_NAME.pem &> /dev/null | |
result=$? | |
if [[ $result -ne 0 ]]; then | |
echo "Error while adding bastion key." | |
exit 1 | |
fi | |
ssh -A "ec2-user@$BASTION_URL" -CND "$PROXY_PORT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment