Skip to content

Instantly share code, notes, and snippets.

@michaelhood
Created September 22, 2012 04:05
Show Gist options
  • Save michaelhood/3765076 to your computer and use it in GitHub Desktop.
Save michaelhood/3765076 to your computer and use it in GitHub Desktop.
EC2 SSH-by-Instance-ID
# ssh $(ec2ip i-a1b2c3d)
function ec2ip() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f17); echo $ip; fi }
function ec2pip() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f18); echo $ip; fi }
function ec2host() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f4); echo $ip; fi }
# ec2ssh i-a1b2c3d
function ec2ssh() { if [ "$#" -gt 0 ]; then ip=$(ec2din --show-empty-fields -H $1 | grep "^INST" | cut -f4); echo $ip; ssh $ip; fi }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment