Class: Proxy::RemoteExecution::Ssh::Runners::AuthenticationMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, prompt: nil, password: nil) ⇒ AuthenticationMethod

Returns a new instance of AuthenticationMethod.



26
27
28
29
30
31
# File 'lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb', line 26

def initialize(name, prompt: nil, password: nil)
  @name = name
  @prompt = prompt
  @password = password
  @errors = nil
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



25
26
27
# File 'lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb', line 25

def errors
  @errors
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb', line 24

def name
  @name
end

Instance Method Details

#ssh_command_prefixObject



33
34
35
36
37
38
# File 'lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb', line 33

def ssh_command_prefix
  return [] unless @password

  prompt = ['-P', @prompt] if @prompt
  [{'SSHPASS' => SensitiveString.new(@password)}, 'sshpass', '-e', prompt].compact
end

#ssh_optionsObject



40
41
42
43
# File 'lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb', line 40

def ssh_options
  ["-o PreferredAuthentications=#{name}",
   "-o NumberOfPasswordPrompts=#{@password ? 1 : 0}"]
end