Module: TestLab::Container::SSH

Included in:
TestLab::Container
Defined in:
lib/testlab/container/ssh.rb

Instance Method Summary collapse

Instance Method Details

#ssh(options = {}) ⇒ ZTK::SSH

ZTK:SSH object

Returns a ZTK:SSH class instance configured for this container.

Returns:

  • (ZTK::SSH)

    An instance of ZTK::SSH configured for this container.



12
13
14
# File 'lib/testlab/container/ssh.rb', line 12

def ssh(options={})
  self.node.container_ssh(self, options)
end

#ssh_configString

Returns text suitable for use in an SSH configuration file

Returns:

  • (String)

    SSH configuration text blob.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/testlab/container/ssh.rb', line 19

def ssh_config
  identities = [self.users.map(&:identity), self.node.identity].flatten.compact.uniq

  output = <<-EOF
#{ZTK::Template.do_not_edit_notice(:message => %(TestLab "#{self.id}" SSH Configuration))}
Host #{self.id}
  HostName #{self.ip}
  Port 22
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  ForwardAgent no
  IdentitiesOnly yes
EOF

  identities.each do |identity|
    output += "  IdentityFile #{identity}\n"
  end

  output
end