Class: AWS_SSH::SSH

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_ssh/ssh.rb

Class Method Summary collapse

Class Method Details

.existing_proxy_commandObject

scan original ssh config file for a proxy command, offer to use that



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aws_ssh/ssh.rb', line 14

def self.existing_proxy_command
  cmd = nil
  found = ""
  filename = ENV['HOME']+"/.ssh/"+AWS_SSH::BASE_HOSTS_FILE
  if File.exists?(filename)
    content = File.open(filename, "r"){ |f| f.read}
    found = content[/ProxyCommand.*/i,0].gsub!("ProxyCommand", "").to_s.strip
  end
  extras = if found.length > 0 then "(Found '#{found}', enter y to use, fill in your own or leave blank for no)" else "" end
  puts "Do you want to use a ProxyCommand? #{extras}: ".colorize(:yellow)
  newcmd = gets.chomp
  cmd = if newcmd.length > 0 && newcmd == "y" && ! found.nil? then found elsif newcmd.length >0 then newcmd else "" end
  return cmd
end

.proxyObject



5
6
7
8
9
10
11
# File 'lib/aws_ssh/ssh.rb', line 5

def self.proxy
  if AWS_SSH::SSH.ssh_proxy_per_host? && (cmd = AWS_SSH::SSH.existing_proxy_command) && ! cmd.nil?
    return cmd
  else
    return nil
  end
end

.ssh_proxy_per_host?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/aws_ssh/ssh.rb', line 33

def self.ssh_proxy_per_host?
  no_proxy_version = 6.6
  return AWS_SSH::SSH.ssh_version < no_proxy_version
end

.ssh_versionObject



29
30
31
# File 'lib/aws_ssh/ssh.rb', line 29

def self.ssh_version
  return `ssh -V 2>&1`[/[0-9]\.[0-9]/i, 0].to_f
end