module Proxy::RemoteExecution::Ssh

Constants

VERSION

Public Class Methods

private_key_file() click to toggle source
# File lib/smart_proxy_remote_execution_ssh.rb, line 26
def private_key_file
  File.expand_path(Plugin.settings.ssh_identity_key_file)
end
public_key_file() click to toggle source
# File lib/smart_proxy_remote_execution_ssh.rb, line 30
def public_key_file
  File.expand_path("#{private_key_file}.pub")
end
validate!() click to toggle source
# File lib/smart_proxy_remote_execution_ssh.rb, line 9
def validate!
  unless private_key_file
    raise "settings for `ssh_identity_key` not set"
  end

  unless File.exist?(private_key_file)
    raise "Ssh public key file #{private_key_file} doesn't exist.\n"\
      "You can generate one with `ssh-keygen -t rsa -b 4096 -f #{private_key_file} -N ''`"
  end

  unless File.exist?(public_key_file)
    raise "Ssh public key file #{public_key_file} doesn't exist"
  end

  validate_ssh_log_level!
end
validate_ssh_log_level!() click to toggle source
# File lib/smart_proxy_remote_execution_ssh.rb, line 34
def validate_ssh_log_level!
  wanted_level = Plugin.settings.ssh_log_level.to_s
  levels = Plugin::SSH_LOG_LEVELS
  unless levels.include? wanted_level
    raise "Wrong value '#{Plugin.settings.ssh_log_level}' for ssh_log_level, must be one of #{levels.join(', ')}"
  end

  current = ::Proxy::SETTINGS.log_level.to_s.downcase

  # regular log levels correspond to upcased ssh logger levels
  ssh, regular = [wanted_level, current].map do |wanted|
    levels.each_with_index.find { |value, _index| value == wanted }.last
  end

  if ssh < regular
    raise 'ssh_log_level cannot be more verbose than regular log level'
  end

  Plugin.settings.ssh_log_level = Plugin.settings.ssh_log_level.to_sym
end