From 953b429788ddafe4330b5a776fa35ec4da45ef3e Mon Sep 17 00:00:00 2001 From: John Weatherford Date: Tue, 29 Jul 2014 18:28:58 -0700 Subject: [PATCH] Added the -o option to allow more SSH options The -o option will allow users to specify an ssh key or any other ssh parameter to CSSH from the command line -o will take precedence over the -l parameter Added in code to print the help message when no parameters were passed --- README.md | 2 ++ bin/cluster | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 81b18e8..a51cc41 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,14 @@ Note: Mac users with the latest version of XCode may run into a compilation err -l, --login [USER] Log in with this user -t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. -t 'role=web,database environment=dev') -r, --region [REGION] AWS region + -o, --options [SSH_OPTIONS] ssh options to pass directly to cssh -s, --screen [SCREEN] What screen to use for clustering windows (form multiple displays) -p, --use-public-ip Use public IP (default false) $cluster -t Name=web,database #Connects to all web and database servers $cluster -t 'role=web,database environment=dev' #Connects to all web and database servers in the dev environment + $cluster -t 'role=web,database environment=dev' -o"-i /Path/to/key.pem" # connect using explicit private key ## Notes diff --git a/bin/cluster b/bin/cluster index 703f2e8..0e134a2 100755 --- a/bin/cluster +++ b/bin/cluster @@ -10,7 +10,7 @@ options = { } OptionParser.new do |opts| - opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]" + opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region] [-o SSH_OPTIONS]" opts.on("-l", "--login [USER]", "Log in with this user") do |opt| options['user'] = opt @@ -32,6 +32,11 @@ OptionParser.new do |opts| options['use_public_ip'] = true end + #Allow -o to be passed to give specific ssh options + opts.on("-o", "--options [SSH_OPTIONS]", "ssh options to pass directly to cssh") do |opt| + options['SSH_OPTIONS'] = opt + end + end.parse! Aws.config.update({:region => options['region']}) @@ -80,6 +85,7 @@ end cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh' cmd = "#{cssh}" +cmd = cmd + " --ssh_args '#{options['SSH_OPTIONS']}'" cmd = cmd + " -l #{options['user']}" unless options['user'].nil? cmd = cmd + " -screen #{options['screen']}" unless options['screen'].nil? cmd = cmd + " #{matched_instances.join ' '}"