Last active
September 10, 2015 01:08
-
-
Save mdumrauf/e8f9a10671a2b201e43a to your computer and use it in GitHub Desktop.
Utility script for connecting to EC2 instances
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
#/bin/sh | |
INSTANCE=$1 | |
if [ -z $INSTANCE ]; then | |
printf 'Usage: connect [instance]\n' | |
echo '[instance] : nginx | production | staging | mongo | what' | |
exit 1; | |
fi | |
if [ $INSTANCE != 'what' ]; then printf "Connecting to $INSTANCE\n"; fi | |
USER="ec2-user" | |
case $INSTANCE in | |
'nginx' ) IP=xx.x.x.xxx | |
;; | |
'production' ) IP=xx.x.x.xxx | |
;; | |
'staging' ) IP=xx.x.x.xxx && USER="ubuntu" | |
;; | |
'mongo' ) IP=xx.x.x.xxx | |
;; | |
'what' ) printf "nginx: xx.x.x.xxx\nproduction: xx.x.x.xxx\nstaging: xx.x.x.xxx\nmongo: xx.x.x.xxx\n" && exit 1; | |
;; | |
* ) echo "Instance unknown." && exit 1; | |
;; | |
esac | |
ssh -i ~/.ssh/key.pem "$USER@$IP" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment