Skip to content
This repository
Browse code

Added optional identity file to ssh configuration

  • Loading branch information...
commit 135cb40214ad51d3d62a379bc54cafd20ef0a008 1 parent e434165
Dave Tapley authored May 31, 2012
4  lib/claws/command/ec2.rb
@@ -33,7 +33,9 @@ def self.exec(options)
33 33
 
34 34
           puts 'connecting to server...'
35 35
 
36  
-          system "ssh #{config.ssh.user}@#{instances[selection.to_i].dns_name}"
  36
+          identity = config.ssh.identity.nil? ? '' : "-i #{config.ssh.identity} "
  37
+
  38
+          system "ssh #{identity}#{config.ssh.user}@#{instances[selection.to_i].dns_name}"
37 39
         end
38 40
       end
39 41
     end
1  lib/claws/command/initialize.rb
@@ -10,6 +10,7 @@ def self.exec
10 10
           },
11 11
           'ssh' => {
12 12
             'user' => nil,
  13
+            'identity' => nil,
13 14
           },
14 15
           'aws' => {
15 16
             'access_key_id' => nil,
10  spec/command/ec2_spec.rb
@@ -102,7 +102,9 @@
102 102
           OpenStruct.new(
103 103
             {
104 104
               :ssh => OpenStruct.new(
105  
-                { :user => 'test' }
  105
+                { :user => 'test',
  106
+                  :identity => 'my_id'
  107
+                }
106 108
               ),
107 109
               :ec2 => OpenStruct.new(
108 110
                 :fields => {
@@ -130,7 +132,7 @@
130 132
           )
131 133
 
132 134
           subject.should_receive(:puts).twice
133  
-          subject.should_receive(:system).with('ssh test@test.com').and_return(0)
  135
+          subject.should_receive(:system).with('ssh -i my_id test@test.com').and_return(0)
134 136
 
135 137
           capture_stdout {
136 138
             subject.exec options
@@ -153,7 +155,7 @@
153 155
           )
154 156
 
155 157
           subject.should_receive(:puts).twice
156  
-          subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
  158
+          subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)
157 159
 
158 160
           capture_stdout {
159 161
             subject.exec OpenStruct.new( {:selection => 1, :config_file => nil, :connect => true} )
@@ -168,7 +170,7 @@
168 170
 
169 171
           subject.should_receive(:gets).and_return('1\n')
170 172
           subject.should_receive(:puts).once
171  
-          subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
  173
+          subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)
172 174
 
173 175
           capture_stdout {
174 176
             subject.exec options

0 notes on commit 135cb40

Please sign in to comment.
Something went wrong with that request. Please try again.