Skip to content

Instantly share code, notes, and snippets.

@avshabanov
Created August 6, 2016 03:27
Show Gist options
  • Save avshabanov/28d12a894b7f1298ae8ac99e3a2b7d74 to your computer and use it in GitHub Desktop.
Save avshabanov/28d12a894b7f1298ae8ac99e3a2b7d74 to your computer and use it in GitHub Desktop.
AWS Scripts
# !/bin/bash
# Easy-to-use access to AWS EC2 - e.g. sshawsn.sh test 1
# hosts.txt - contains ec2 public DNS records
PEM_FILE=$HOME/opt/config/aws/$1.pem
if [ ! -f $PEM_FILE ]; then
echo "Non-existent pem file: $PEM_FILE"
exit -1
fi
HOST_FILE=$HOME/opt/config/aws/hosts.txt
HOST=`sed "$2q;d" $HOST_FILE`
if [ -z "$HOST" ]; then
echo "Invalid host number"
exit -1
fi
echo "Logging in to $HOST"
ssh -i $PEM_FILE $HOST -l ec2-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment