Class: Conjure::Service::ForwardedShell
- Inherits:
-
Object
- Object
- Conjure::Service::ForwardedShell
- Defined in:
- lib/conjure/service/forwarded_shell.rb
Instance Method Summary collapse
- #command(c) ⇒ Object
-
#initialize(options) ⇒ ForwardedShell
constructor
A new instance of ForwardedShell.
Constructor Details
#initialize(options) ⇒ ForwardedShell
Returns a new instance of ForwardedShell.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/conjure/service/forwarded_shell.rb', line 4 def initialize() @shell = [:shell].prepare( :label => "forwarded", :setup_commands => [ "apt-get install -y openssh-server", "mkdir -p /var/run/sshd", "mkdir -p /root/.ssh; echo '#{[:public_key]}' > /root/.ssh/authorized_keys", "chmod 600 /root/.ssh/authorized_keys" ], ) end |
Instance Method Details
#command(c) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/conjure/service/forwarded_shell.rb', line 16 def command(c) container = @shell.run "/usr/sbin/sshd -D -e" escaped_command = @shell.docker_host.shell_escape c ssh_command = "ssh -A -o StrictHostKeyChecking=no -o PasswordAuthentication=no #{container.ip_address} '#{escaped_command}'" result = @shell.docker_host.server.run ssh_command result.stdout end |