Permalink
Browse files

Added optional identity file to ssh configuration

  • Loading branch information...
1 parent e434165 commit 135cb40214ad51d3d62a379bc54cafd20ef0a008 @dukedave dukedave committed May 31, 2012
Showing with 10 additions and 5 deletions.
  1. +3 −1 lib/claws/command/ec2.rb
  2. +1 −0 lib/claws/command/initialize.rb
  3. +6 −4 spec/command/ec2_spec.rb
View
4 lib/claws/command/ec2.rb
@@ -33,7 +33,9 @@ def self.exec(options)
puts 'connecting to server...'
- system "ssh #{config.ssh.user}@#{instances[selection.to_i].dns_name}"
+ identity = config.ssh.identity.nil? ? '' : "-i #{config.ssh.identity} "
+
+ system "ssh #{identity}#{config.ssh.user}@#{instances[selection.to_i].dns_name}"
end
end
end
View
1 lib/claws/command/initialize.rb
@@ -10,6 +10,7 @@ def self.exec
},
'ssh' => {
'user' => nil,
+ 'identity' => nil,
},
'aws' => {
'access_key_id' => nil,
View
10 spec/command/ec2_spec.rb
@@ -102,7 +102,9 @@
OpenStruct.new(
{
:ssh => OpenStruct.new(
- { :user => 'test' }
+ { :user => 'test',
+ :identity => 'my_id'
+ }
),
:ec2 => OpenStruct.new(
:fields => {
@@ -130,7 +132,7 @@
)
subject.should_receive(:puts).twice
- subject.should_receive(:system).with('ssh test@test.com').and_return(0)
+ subject.should_receive(:system).with('ssh -i my_id test@test.com').and_return(0)
capture_stdout {
subject.exec options
@@ -153,7 +155,7 @@
)
subject.should_receive(:puts).twice
- subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
+ subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)
capture_stdout {
subject.exec OpenStruct.new( {:selection => 1, :config_file => nil, :connect => true} )
@@ -168,7 +170,7 @@
subject.should_receive(:gets).and_return('1\n')
subject.should_receive(:puts).once
- subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
+ subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)
capture_stdout {
subject.exec options

0 comments on commit 135cb40

Please sign in to comment.