Skip to content

Instantly share code, notes, and snippets.

@llbbl
Created September 7, 2016 00:10
Show Gist options
  • Save llbbl/cb2dc93fda9203ee7141d5db263c8ea7 to your computer and use it in GitHub Desktop.
Save llbbl/cb2dc93fda9203ee7141d5db263c8ea7 to your computer and use it in GitHub Desktop.
function ec2-ssh () {
ssh -i ~/.ssh/$2 -l ubuntu $(aws ec2 describe-instances --filter Name=instance-id,Values=$1 | jq '.Reservations[0].Instances[0].PublicIpAddress' | tr -d '"')
}
@llbbl
Copy link
Author

llbbl commented Sep 7, 2016

Assumes you are running ubuntu. Assumes you have AWS-CLI installed and configured. Drop this in .bashrc or .zshrc.

Usage:

ec2-ssh instanceId keyFile

Setup Aliases in your .bashrc or .zshrc file instead of using .ssh/config

alias serverName="ec2-ssh instanceId keyFile"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment