Class: Toolshed::Commands::SSH

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/commands/ssh.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cli_optionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/toolshed/commands/ssh.rb', line 6

def self.cli_options
  {
    banner: 'Usage: ssh [options]',
    options: {
      use_sudo: {
        short_on: '-e'
      },
      host: {
        short_on: '-o'
      },
      connection_string_options: {
        short_on: '-n'
      },
      commands: {
        short_on: '-c'
      },
      password: {
        short_on: '-p'
      },
      prompt_for_password: {
        short_on: '-r'
      },
      user: {
        short_on: '-u'
      },
      keys: {
        short_on: '-k'
      },
      sudo_password: {
        short_on: '-s'
      },
      verbose_output: {
        short_on: '-v'
      },
      timeout_period: {
        short_on: '-t'
      }
    }
  }
end

Instance Method Details

#execute(args, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/toolshed/commands/ssh.rb', line 47

def execute(args, options = {})
  Toolshed.logger.info "Running ssh command with options #{options.inspect}" unless options[:verbose_output].nil? || options[:verbose_output].empty? # rubocop:disable Metrics/LineLength
  begin
    ssh = Toolshed::ServerAdministration::SSH.new(options)
    ssh.execute
  rescue => e
    Toolshed.logger.fatal e.message
    Toolshed.logger.fatal "Unable to connect to #{options[:host]}"
    Toolshed.die
  end
end