Sha256: 99f0c2ab503d3af57d2004af0283b7f713ac874b6d2bb32c1668bab3caaab1f6

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

command :ssh do |c|
  c.summary = 'Connects to a host or a container with SSH'
  c.syntax = 'ops ssh [host_name] [container_name]'
  c.description = "SSH connection to host or one of its containers if write [container_name]"
  c.example "Connects to host:", 'ops ssh example.com'
  c.example "Connects to a container:", 'ops ssh example.com www'
  c.action do |args, options|
    host = args[0]
    user = Docker::DEFAULT_USER

    if args.count == 1
      ssh_port = 22
    else
      container = args[1]
      containers = Docker::containers_for(host)
      ssh_port = Docker::get_container_port containers[container]
    end
    command = "ssh #{user}@#{host} -p #{ssh_port}"

    puts "CMD: #{command}"
    exec command
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
open-dock-0.1.6 lib/open-dock/commands/ssh_host.rb
open-dock-0.1.5 lib/open-dock/commands/ssh_host.rb
open-dock-0.1.3 lib/open-dock/commands/ssh_host.rb