Skip to content

Commit 953b429

Browse files
h2o8polobubenkoff
authored andcommitted
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
1 parent 6f77982 commit 953b429

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ Note: Mac users with the latest version of XCode may run into a compilation err
2727
-l, --login [USER] Log in with this user
2828
-t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. -t 'role=web,database environment=dev')
2929
-r, --region [REGION] AWS region
30+
-o, --options [SSH_OPTIONS] ssh options to pass directly to cssh
3031
-s, --screen [SCREEN] What screen to use for clustering windows (form multiple displays)
3132
-p, --use-public-ip Use public IP (default false)
3233

3334

3435
$cluster -t Name=web,database #Connects to all web and database servers
3536
$cluster -t 'role=web,database environment=dev' #Connects to all web and database servers in the dev environment
37+
$cluster -t 'role=web,database environment=dev' -o"-i /Path/to/key.pem" # connect using explicit private key
3638

3739
## Notes
3840

bin/cluster

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ options = {
1010
}
1111

1212
OptionParser.new do |opts|
13-
opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]"
13+
opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region] [-o SSH_OPTIONS]"
1414

1515
opts.on("-l", "--login [USER]", "Log in with this user") do |opt|
1616
options['user'] = opt
@@ -32,6 +32,11 @@ OptionParser.new do |opts|
3232
options['use_public_ip'] = true
3333
end
3434

35+
#Allow -o to be passed to give specific ssh options
36+
opts.on("-o", "--options [SSH_OPTIONS]", "ssh options to pass directly to cssh") do |opt|
37+
options['SSH_OPTIONS'] = opt
38+
end
39+
3540
end.parse!
3641

3742
Aws.config.update({:region => options['region']})
@@ -80,6 +85,7 @@ end
8085
cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh'
8186

8287
cmd = "#{cssh}"
88+
cmd = cmd + " --ssh_args '#{options['SSH_OPTIONS']}'"
8389
cmd = cmd + " -l #{options['user']}" unless options['user'].nil?
8490
cmd = cmd + " -screen #{options['screen']}" unless options['screen'].nil?
8591
cmd = cmd + " #{matched_instances.join ' '}"

0 commit comments

Comments
 (0)