aws_ssh 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 309d8060f416544bfc2f694b9e52e9a1d0959c88
4
- data.tar.gz: f10639efda3bfb3d036886b865559320471dba4d
3
+ metadata.gz: 14171af4055f9cec7390e3b1b0a63e3554fc173f
4
+ data.tar.gz: 1da138031a9c079484ae282bf35046c4e18b048a
5
5
  SHA512:
6
- metadata.gz: 08db6a7f98e7e501c61c84dddf558c3614f46866d0d1a634750a85811d8b3f57abaef5cef29a062f7be69cb4b1674b248e9836e68709578ab73b92feffbf756c
7
- data.tar.gz: 44c0e9cb3d52f917c6d548c96650ec837352067ddc96cb244b3ee68d23d578f628285fa4a6bbae313ce3a49d6fc34627fc633da8bd542701c20ce4f5b96ff4c9
6
+ metadata.gz: 83dd28ff9fcae85abd860ac20f89fb21e0c2f0a0fda3b0579c3d3ecb90cfd0f052afb8135ae84e5c431dcc25a38287f156f8ac68afb21990124f0a36d59125f7
7
+ data.tar.gz: ecb116933c9dafbdb88898aeaaaace8b4cb5becfed2ce7af45c36e9a3ebc139483e95e1dff3a1b6b9ea63427ea3a219eb176aa977075a14133ca3b5a351d9293
data/README.md CHANGED
@@ -28,9 +28,11 @@ You can also have as many services and environments as you like, they just have
28
28
 
29
29
  ## Install ##
30
30
 
31
+ gem install aws_ssh && aws_ssh_setup
31
32
 
32
33
  ### Uninstall ###
33
34
 
35
+ aws_ssh_teardown && gem uninstall aws_ssh
34
36
 
35
37
  ## Usage ##
36
38
 
data/lib/aws_ssh/ec2.rb CHANGED
@@ -12,7 +12,7 @@ module AWS_SSH
12
12
  # aws api object
13
13
  attr_accessor :api
14
14
  # suffix of the key to use
15
- attr_accessor :ssh_key_suffix
15
+ attr_accessor :ssh_key_suffixes
16
16
  # auto generated ssh config_file
17
17
  attr_accessor :ssh_config_file
18
18
  # value used as seperater in the tags
@@ -36,7 +36,7 @@ module AWS_SSH
36
36
  @LogLevel = "quiet"
37
37
 
38
38
  @seperator = "."
39
- @ssh_key_suffix = "pem"
39
+ @ssh_key_suffixes = [".pem", ""]
40
40
  @api = AWS::EC2.new(access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], region: ENV['AWS_REGION'])
41
41
  end
42
42
 
@@ -53,6 +53,9 @@ module AWS_SSH
53
53
 
54
54
  def instance_data(instance)
55
55
  tags = instance.tags.to_h
56
+ key_file = nil
57
+ base = ENV['HOME']+"/.ssh/"+instance.key_name
58
+ @ssh_key_suffixes.each{|k| if File.exists?(base+k) then key_file = base+k end }
56
59
  return {
57
60
  :name => if tags["Name"].nil? then nil else tags["Name"].to_s.strip end,
58
61
  :user => if tags["user"].nil? then @User else tags["user"].to_s.strip end,
@@ -60,7 +63,7 @@ module AWS_SSH
60
63
  :services => if tags["service"].nil? then nil else tags["service"].split(@seperator) end,
61
64
  :ip => instance.private_ip_address,
62
65
  :key => instance.key_name,
63
- :key_file => ENV['HOME']+"/.ssh/"+instance.key_name+"."+@ssh_key_suffix
66
+ :key_file => key_file
64
67
  }
65
68
  end
66
69
 
@@ -82,7 +85,7 @@ module AWS_SSH
82
85
  hosts = {}
83
86
  self.instances.select!{|i| i.status.to_s == "running"}.each do |i|
84
87
  info = self.instance_data(i)
85
- if File.exists?(info[:key_file])
88
+ if !info[:key_file].nil?
86
89
  self.instance_names(info).each{ |h| hosts[h] = info}
87
90
  end
88
91
  end
@@ -100,7 +103,7 @@ module AWS_SSH
100
103
  config += "Host #{name}\n"
101
104
  config += " HostName #{host[:ip].to_s}\n"
102
105
  config += " User #{host[:user].to_s}\n"
103
- config += " IdentityFile ~/.ssh/#{host[:key].to_s}.#{@ssh_key_suffix}\n"
106
+ config += " IdentityFile #{host[:key_file]}\n"
104
107
  config += " StrictHostKeyChecking #{@StrictHostKeyChecking}\n"
105
108
  config += " UserKnownHostsFile #{@UserKnownHostsFile}\n"
106
109
  config += " LogLevel #{@LogLevel}\n"
@@ -1,3 +1,3 @@
1
1
  module AWS_SSH
2
- VERSION="0.1.0"
2
+ VERSION="0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Marshall