Class: Dkdeploy::InteractionHandler::Password

Inherits:
Object
  • Object
show all
Defined in:
lib/dkdeploy/interaction_handler/password.rb

Overview

Interaction handler for password

Instance Method Summary collapse

Constructor Details

#initialize(password) ⇒ Password

Interaction handler for password



8
9
10
# File 'lib/dkdeploy/interaction_handler/password.rb', line 8

def initialize(password)
  @password = password
end

Instance Method Details

#on_data(_command, _stream_name, data, channel) ⇒ Object

Method to send password to terminal

Parameters:

  • _command (SSHKit::Command)
  • _stream_name (Symbol)
  • data (String)
  • channel (Net::SSH::Connection::Channel)


18
19
20
21
22
23
24
25
# File 'lib/dkdeploy/interaction_handler/password.rb', line 18

def on_data(_command, _stream_name, data, channel)
  if data =~ /.*password.*/i
    channel.send_data("#{@password}\n")
  else
    channel.close
    raise 'Unexpected data from stream. Can not send password to undefined stream'
  end
end