Sha256: ccda934677cd834947136af0bba6ca7ad09db754ef0a8874020fdf17b4e3cc0a

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require_relative '../../bolt/logger'
require_relative '../../bolt/node/errors'
require_relative '../../bolt/transport/simple'

module Bolt
  module Transport
    class SSH < Simple
      def initialize
        super

        require 'net/ssh'
        require 'net/scp'
        begin
          require 'net/ssh/krb'
        rescue LoadError
          logger.debug("Authentication method 'gssapi-with-mic' (Kerberos) is not available.")
        end
        @transport_logger = Bolt::Logger.logger(Net::SSH)
        @transport_logger.level = :warn
      end

      def with_connection(target)
        if target.transport_config['ssh-command'] && !target.transport_config['native-ssh']
          Bolt::Logger.warn_once("native_ssh_disabled", "native-ssh must be true to use ssh-command")
        end

        conn = if target.transport_config['native-ssh']
                 ExecConnection.new(target)
               else
                 Connection.new(target, @transport_logger)
               end
        conn.connect
        yield conn
      ensure
        begin
          conn&.disconnect
        rescue StandardError => e
          logger.info("Failed to close connection to #{target.safe_name} : #{e.message}")
        end
      end
    end
  end
end

require_relative 'ssh/connection'
require_relative 'ssh/exec_connection'

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bolt-4.0.0 lib/bolt/transport/ssh.rb
bolt-3.29.0 lib/bolt/transport/ssh.rb
bolt-3.28.0 lib/bolt/transport/ssh.rb
bolt-3.27.4 lib/bolt/transport/ssh.rb
bolt-3.27.2 lib/bolt/transport/ssh.rb
bolt-3.27.1 lib/bolt/transport/ssh.rb
bolt-3.26.2 lib/bolt/transport/ssh.rb
bolt-3.26.1 lib/bolt/transport/ssh.rb
bolt-3.25.0 lib/bolt/transport/ssh.rb
bolt-3.24.0 lib/bolt/transport/ssh.rb
bolt-3.23.1 lib/bolt/transport/ssh.rb
bolt-3.23.0 lib/bolt/transport/ssh.rb
bolt-3.22.1 lib/bolt/transport/ssh.rb
bolt-3.22.0 lib/bolt/transport/ssh.rb
bolt-3.21.0 lib/bolt/transport/ssh.rb
bolt-3.20.0 lib/bolt/transport/ssh.rb
bolt-3.19.0 lib/bolt/transport/ssh.rb
bolt-3.18.0 lib/bolt/transport/ssh.rb