Class: MarhanCli::NetworkCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/marhan_cli/commands/network_command.rb

Instance Method Summary collapse

Instance Method Details

#add_ssh_keyObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/marhan_cli/commands/network_command.rb', line 34

def add_ssh_key
  host = get_or_ask(:host)
  user = get_or_ask(:user)
  password = get_or_ask(:password)
  id_file = get(:file)
  port = get(:port)

  remote_machine = RemoteMachine.new(host, port)
  remote_machine.add_id_to_authorized_keys(user, password, id_file)
  say "successfully copied #{id_file} to #{host}", :green
rescue Exception => e
  exit_with_error("copying of id file to remote machine failed: #{e}")
end