Module: Cuken::Api::Ssh

Defined in:
lib/cuken/api/ssh.rb,
lib/cuken/api/ssh/password.rb

Instance Method Summary collapse

Instance Method Details

#ssh_client_hostname(n = nil) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/cuken/api/ssh.rb', line 76

def ssh_client_hostname(n=nil)
  name = ENV['HOSTNAME']|| ENV['HOST']||ENV['COMPUTERNAME']||ENV['COMPUTER']||(`hostname`).strip rescue 'localhost'
  if @ssh_forever_options
    @ssh_forever_options[:user] = n.nil? ? name : n
  end
  name
end

#ssh_client_username(n = nil) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/cuken/api/ssh.rb', line 84

def ssh_client_username(n=nil)
  name = ENV['USER']|| ENV['USERNAME']|| (`whoami`).strip rescue 'root'
  if @ssh_forever_options
    @ssh_forever_options[:hostname] = n.nil? ? name : n
  end
  name
end

#ssh_forever_init_password_less_batch(table = nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cuken/api/ssh.rb', line 50

def ssh_forever_init_password_less_batch(table=nil)
  if table == :default
    return @ssh_forever_options = ssh_forever_default_options
  elsif table.nil?
    return @ssh_forever_options ||={}
  end
  table.hashes.each do |hash|
    hsh = parse_ssh_forever_options(hash)
    cmd = ssh_forever(hsh)
    run_simple(unescape(cmd))
  end
end

#ssh_forever_options(table = nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cuken/api/ssh.rb', line 63

def ssh_forever_options(table=nil)
  if table == :default
    return @ssh_forever_options = ssh_forever_default_options
  elsif table.nil?
    return @ssh_forever_options ||={}
  end
  table.hashes.each do |hash|
    hsh = parse_ssh_forever_options(hash)
    cmd = ssh_forever(hsh)
    run_simple(unescape(cmd))
  end
end

#ssh_init_password_lessObject



8
9
10
11
12
# File 'lib/cuken/api/ssh.rb', line 8

def ssh_init_password_less
  @ssh_options ||= ssh_default_options
  cmd = ssh_cmd(@ssh_options)
  announce_or_puts(unescape(cmd))
end

#ssh_init_password_less_batch(table = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cuken/api/ssh.rb', line 14

def ssh_init_password_less_batch(table=nil)
  if table == :default
    return @ssh_options = ssh_default_options
  elsif table.nil?
    return @ssh_options ||={}
  end
  @ssh_options ||={}
  table.hashes.each do |hash|
    hsh = parse_ssh_options(hash)
    cmd = ssh_cmd(hsh)
    ssh_run(cmd)
  end
end

#ssh_init_password_less_interactive(table = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cuken/api/ssh.rb', line 28

def ssh_init_password_less_interactive(table=nil)
  if table == :default
    return @ssh_options = ssh_default_options
  elsif table.nil?
    return @ssh_options ||={}
  end
  @ssh_options ||={}
  table.hashes.each do |hash|
    hsh = parse_ssh_options(hash)
    cmd = ssh_cmd(hsh)
    (cmd)
  end
end

#ssh_login_interactive(cmd) ⇒ Object



46
47
48
# File 'lib/cuken/api/ssh.rb', line 46

def (cmd)
  run_interactive(unescape(cmd))
end

#ssh_run(cmd) ⇒ Object



42
43
44
# File 'lib/cuken/api/ssh.rb', line 42

def ssh_run(cmd)
  run_simple(unescape(cmd))
end