From 62967d4a2ff5804c816025698f667e27ea40b6ed Mon Sep 17 00:00:00 2001 From: jiluo Date: Wed, 13 Nov 2013 16:29:21 +0800 Subject: [PATCH 1/2] Add -i option to ec2-ssh, so that user can specify identity file when connecting --- bin/ec2-ssh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/ec2-ssh b/bin/ec2-ssh index 3afd98b..a2f790f 100755 --- a/bin/ec2-ssh +++ b/bin/ec2-ssh @@ -4,17 +4,18 @@ set -e usage() { cat< +Usage: ec2-ssh [-k KEY] [-s SECRET] [-r REGION] [-i IDENTITY_FILE] [-t TAG] Open an ssh connection to an EC2 instance where =tag:value. The 'tag:' portion of is optional, and defaults to 'Name'. For a list of instances, run ec2-host without any paramteres - -h display this help and exit - -k, KEY Amazon EC2 Key, defaults to \$AWS_ACCESS_KEY_ID - -s, SECRET Amazon EC2 Secret, defaults to \$AWS_SECRET_ACCESS_KEY - -r, REGION Amazon EC2 Region, defaults to us-east-1 - -t, TAG Tag name for searching, defaults to 'Name' + -h display this help and exit + -k, KEY Amazon EC2 Key, defaults to \$AWS_ACCESS_KEY_ID + -s, SECRET Amazon EC2 Secret, defaults to \$AWS_SECRET_ACCESS_KEY + -r, REGION Amazon EC2 Region, defaults to us-east-1 + -i, IDENTITY_FILE Amazon EC2 Identity File, defaults to \$HOME/.ssh/id_rsa + -t, TAG Tag name for searching, defaults to 'Name' EOF } @@ -23,13 +24,14 @@ test $# -eq 0 && { usage; exit; } # Process options cmd="ec2-host" -while getopts ":hk:s:r:t:" opt; do +while getopts ":hk:s:r:t:i:" opt; do case $opt in h ) usage; exit 1;; k ) cmd="$cmd -k $OPTARG";; s ) cmd="$cmd -s $OPTARG";; r ) cmd="$cmd -r $OPTARG";; t ) cmd="$cmd -t $OPTARG";; + i ) identity_file=$OPTARG;; \? ) usage; exit 1 esac done @@ -67,4 +69,6 @@ cmd="echo \\\". ~/.bashrc && PS1='\[\e]0;$inst: \w\\\a\]\[\\\033[01;32m\]$inst\[ if test "${@:2}"; then cmd="${@:2}" fi -test -n "$host" && echo "Connecting to $host." && exec sh -c "ssh -t $user@$host \"$cmd\"" +opts="-t" +test -n "$identity_file" && opts="-i $identity_file $opts" +test -n "$host" && echo "Connecting to $host." && exec sh -c "ssh $opts $user@$host \"$cmd\"" From 19f60ab3a6c7e7d3db842b59d2159734dd617017 Mon Sep 17 00:00:00 2001 From: jiluo Date: Fri, 22 Nov 2013 23:06:48 +0800 Subject: [PATCH 2/2] Increase version --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e19c2a0..38e2eed 100644 --- a/setup.py +++ b/setup.py @@ -43,6 +43,7 @@ * 1.1.1 - Add line echoing host before establishing SSH connection * 1.2 - Merged pull requests to add region and tag support * 1.2.1 - Fix issue when ec2-host finds one offline instance with same name as an online instance +* 1.2.2 - Add support for identity file """ @@ -52,7 +53,7 @@ setup( name = "ec2-ssh", - version = "1.2.1", + version = "1.2.2", author = "Shayne Sweeney", author_email = "shayne@instagram.com", description = "SSH into EC2 instances via tag name",