class AWS_SSH::SSH

Public Class Methods

existing_proxy_command() click to toggle source

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

# 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
  if cmd.nil?
    puts "No command selected".colorize(:green)
  else
    puts "Using #{cmd}".colorize(:green)
  end
  return cmd
end
proxy() click to toggle source
# 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?() click to toggle source
# File lib/aws_ssh/ssh.rb, line 38
def self.ssh_proxy_per_host?
  # no_proxy_version = 6.6
  # return AWS_SSH::SSH.ssh_version < no_proxy_version
  true
end
ssh_version() click to toggle source
# File lib/aws_ssh/ssh.rb, line 34
def self.ssh_version
  return `ssh -V 2>&1`[/[0-9]\.[0-9]/i, 0].to_f
end