Skip to content

Instantly share code, notes, and snippets.

@jeffdevine
Last active June 10, 2016 16:32
Show Gist options
  • Save jeffdevine/25c1fff3431dc8d3902065f34eeccf38 to your computer and use it in GitHub Desktop.
Save jeffdevine/25c1fff3431dc8d3902065f34eeccf38 to your computer and use it in GitHub Desktop.
ec2ssh
if [ $# -eq 0 ] ; then
environment="staging"
else
environment=$1
fi
output="$(cap $environment ec2:status | grep 10.)"
ip="$(echo $output | awk '{print $6}' )"
name="$(echo $output | awk '{print tolower($3)}' )"
if [ ! -f "$HOME/.ssh/${name}-$environment.pem" ]; then
cap $environment deploy:download_ec2_key
fi
ssh -i $HOME/.ssh/${name}-$environment.pem deploy@${ip}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment