Skip to content

Instantly share code, notes, and snippets.

@nickrw
Created March 3, 2015 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickrw/d3df63661e9fe7f9d8dd to your computer and use it in GitHub Desktop.
Save nickrw/d3df63661e9fe7f9d8dd to your computer and use it in GitHub Desktop.
ssh-ec2 - designed as an alias replacement of ssh. Will try and convert tags or instance IDs to IPs, and opens sessions in tmux if more than one result is returned
#!/bin/bash
try_ec2="$(resolve-ec2 $@)"
if [[ -z $try_ec2 ]]; then
ssh $@
else
if [[ $(echo "$try_ec2" | wc -l ) -gt 1 ]]; then
mux $1 $try_ec2
else
ssh $try_ec2
fi
fi
@nangnang
Copy link

nangnang commented Mar 3, 2015

!/bin/bash

try_ec2="$(resolve-ec2 $@)"
if [[ -z $try_ec2 ]]; then
ssh $@
else
if [[ $(echo "$try_ec2" | wc -l ) -gt 1 ]]; then
mux $1 $try_ec2
else
ssh $try_ec2
fi
fi

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