aws_ssh 0.1.2 → 0.1.3

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: a29fb3972592fe9a5515f6b0980977736c7b150e
4
- data.tar.gz: 13272a3858270e3a3daeabac3c7c2b82846d544f
3
+ metadata.gz: 97208487d2c251e27a81c10301c979da01928ea2
4
+ data.tar.gz: 57e6395a053378cf986101bd2df3bb684a0c9782
5
5
  SHA512:
6
- metadata.gz: e942774c61463151f57ee62eb45d4c4414047b4b5caeb797792ac9845d9cdf5a2dddf356ac79277213d33f853d1d4ac87bbc83e0c45ea0d54c85e1be8b357ea7
7
- data.tar.gz: c724c62b75f28e1557fcef2ceaebc7b615f448afbca89e57607d90cf7e425f738ace9e4467ec66c0d41d11ce48883dcecc7bb7cd91da7ad623d378add763f309
6
+ metadata.gz: ba46265e16998b3d7f6b81d222df06fe28a7293566197f8d7b926c818bc8e95009824f151b478348396f4b06ca0f952dcb04dd0ab5e60ad8ccf17d30d2ae67e2
7
+ data.tar.gz: 046b002281cbf84fb4db793006bf53ada5e8eb451af88e3bb2fb1104df94f951c40ecced47eddea8fc9f6219af51b8235af99ca2cc384b470777bb5188da5331
data/README.md CHANGED
@@ -8,7 +8,7 @@ It does assume that you are using SSH key based authentication to access the ser
8
8
 
9
9
  Ruby, version 2.0 onwards, is required along with the standard bundler gem.
10
10
 
11
- At the moment, this code is only tested with bash based shells.
11
+ At the moment, this code is only tested with bash based shells whose ssh config is setup around their user (non root, local, not global ssh config etc).
12
12
 
13
13
  ## AWS Configuration ##
14
14
 
@@ -5,6 +5,7 @@ module AWS_SSH
5
5
  require "aws_ssh/exceptions"
6
6
  require "aws_ssh/files"
7
7
  require "aws_ssh/cmds"
8
+ require "aws_ssh/ssh"
8
9
  require "aws_ssh/terminal_formats"
9
10
  require "aws_ssh/ec2"
10
11
  require "aws_ssh/setup"
@@ -8,6 +8,7 @@ module AWS_SSH
8
8
  attr_accessor :StrictHostKeyChecking
9
9
  attr_accessor :UserKnownHostsFile
10
10
  attr_accessor :LogLevel
11
+ attr_accessor :ProxyCommand
11
12
  ### class values
12
13
  # aws api object
13
14
  attr_accessor :api
@@ -34,6 +35,7 @@ module AWS_SSH
34
35
  @StrictHostKeyChecking = "no"
35
36
  @UserKnownHostsFile = "/dev/null"
36
37
  @LogLevel = "quiet"
38
+ @ProxyCommand = AWS_SSH::SSH.proxy
37
39
 
38
40
  @seperator = "."
39
41
  @ssh_key_suffixes = [".pem", ""]
@@ -107,6 +109,7 @@ module AWS_SSH
107
109
  config += " StrictHostKeyChecking #{@StrictHostKeyChecking}\n"
108
110
  config += " UserKnownHostsFile #{@UserKnownHostsFile}\n"
109
111
  config += " LogLevel #{@LogLevel}\n"
112
+ config += if ! @ProxyCommand.nil? then " ProxyCommand #{@ProxyCommand}\n" else "" end
110
113
  config += "\n\n"
111
114
  end
112
115
  # write to file
@@ -2,6 +2,8 @@ require "aws_ssh/files"
2
2
  require "aws_ssh/cache"
3
3
  module AWS_SSH
4
4
  class Run
5
+
6
+
5
7
  def generate
6
8
  config = ENV['HOME']+"/.ssh/"+AWS_SSH::HOSTS_FILE
7
9
  # 4 hour cache
@@ -0,0 +1,39 @@
1
+ module AWS_SSH
2
+
3
+ class SSH
4
+
5
+ def self.proxy
6
+ if AWS_SSH::SSH.ssh_proxy_per_host? && (cmd = AWS_SSH::SSH.existing_proxy_command) && ! cmd.nil?
7
+ return cmd
8
+ else
9
+ return nil
10
+ end
11
+ end
12
+
13
+ # scan original ssh config file for a proxy command, offer to use that
14
+ def self.existing_proxy_command
15
+ cmd = nil
16
+ found = ""
17
+ filename = ENV['HOME']+"/.ssh/"+AWS_SSH::BASE_HOSTS_FILE
18
+ if File.exists?(filename)
19
+ content = File.open(filename, "r"){ |f| f.read}
20
+ found = content[/ProxyCommand.*/i,0].gsub!("ProxyCommand", "").to_s.strip
21
+ end
22
+ extras = if found.length > 0 then "(Found '#{found}', enter y to use, fill in your own or leave blank for no)" else "" end
23
+ puts "Do you want to use a ProxyCommand? #{extras}: ".colorize(:yellow)
24
+ newcmd = gets.chomp
25
+ cmd = if newcmd.length > 0 && newcmd == "y" && ! found.nil? then found elsif newcmd.length >0 then newcmd else "" end
26
+ return cmd
27
+ end
28
+
29
+ def self.ssh_version
30
+ return `ssh -V 2>&1`[/[0-9]\.[0-9]/i, 0].to_f
31
+ end
32
+
33
+ def self.ssh_proxy_per_host?
34
+ no_proxy_version = 6.6
35
+ return AWS_SSH::SSH.ssh_version < no_proxy_version
36
+ end
37
+
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module AWS_SSH
2
- VERSION="0.1.2"
2
+ VERSION="0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-22 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -92,6 +92,7 @@ files:
92
92
  - lib/aws_ssh/files.rb
93
93
  - lib/aws_ssh/runner.rb
94
94
  - lib/aws_ssh/setup.rb
95
+ - lib/aws_ssh/ssh.rb
95
96
  - lib/aws_ssh/teardown.rb
96
97
  - lib/aws_ssh/terminal_formats.rb
97
98
  - lib/aws_ssh/version.rb