Sha256: 9b092a16bb257d5f422d95b5e6069e15b9c666657bf8368ccde10941e17d36cc

Contents?: true

Size: 788 Bytes

Versions: 5

Compression:

Stored size: 788 Bytes

Contents

require 'contracts'
require 'sshkit'

module StackatoLKG
  module SSH
    class Client
      include ::Contracts::Core
      include ::Contracts::Builtin

      Contract String => Client
      def initialize(private_key)  # TODO: Eliminate side-effects
        ::SSHKit::Backend::Netssh.configure do |ssh|
          ssh.ssh_options = {
            config: false,
            auth_methods: ['publickey'],
            keys: private_key
          }
        end

        self
      end

      Contract String, Proc => Any
      def to(host, &block)
        ::SSHKit::Coordinator.new("#{config.ssh_username}@#{host}").each(&block)
      end

      private

      Contract None => ::StackatoLKG::Config
      def config
        @config ||= ::StackatoLKG::Config.new
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloudstrap-0.30.1.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.29.7.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.29.6.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.29.5.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.29.1.pre lib/cloudstrap/ssh/client.rb