Sha256: d5eddf6fc4779db45d5506e3ba5b5f577c0840b9374c8efd5bf688b952941be7

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 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,
            keys_only: true
          }
        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

3 entries across 3 versions & 1 rubygems

Version Path
cloudstrap-0.30.11.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.30.3.pre lib/cloudstrap/ssh/client.rb
cloudstrap-0.30.2.pre lib/cloudstrap/ssh/client.rb