aws_ssh 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/aws_ssh/ec2.rb +8 -5
- data/lib/aws_ssh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14171af4055f9cec7390e3b1b0a63e3554fc173f
|
4
|
+
data.tar.gz: 1da138031a9c079484ae282bf35046c4e18b048a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83dd28ff9fcae85abd860ac20f89fb21e0c2f0a0fda3b0579c3d3ecb90cfd0f052afb8135ae84e5c431dcc25a38287f156f8ac68afb21990124f0a36d59125f7
|
7
|
+
data.tar.gz: ecb116933c9dafbdb88898aeaaaace8b4cb5becfed2ce7af45c36e9a3ebc139483e95e1dff3a1b6b9ea63427ea3a219eb176aa977075a14133ca3b5a351d9293
|
data/README.md
CHANGED
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 :
|
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
|
-
@
|
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 =>
|
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
|
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
|
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"
|
data/lib/aws_ssh/version.rb
CHANGED