Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@llbbl 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