Sha256: 4036ca67fe026e95ce39289c668c055f1fdbcfae6a80005263fe11bb0c12fdb2

Contents?: true

Size: 1.29 KB

Versions: 25

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'bolt/logger'
require 'bolt/node/errors'
require '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 'bolt/transport/ssh/connection'
require 'bolt/transport/ssh/exec_connection'

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
bolt-3.17.0 lib/bolt/transport/ssh.rb
bolt-3.16.1 lib/bolt/transport/ssh.rb
bolt-3.16.0 lib/bolt/transport/ssh.rb
bolt-3.15.0 lib/bolt/transport/ssh.rb
bolt-3.14.1 lib/bolt/transport/ssh.rb
bolt-3.13.0 lib/bolt/transport/ssh.rb
bolt-3.12.0 lib/bolt/transport/ssh.rb
bolt-3.11.0 lib/bolt/transport/ssh.rb
bolt-3.10.0 lib/bolt/transport/ssh.rb
bolt-3.9.2 lib/bolt/transport/ssh.rb
bolt-3.9.1 lib/bolt/transport/ssh.rb
bolt-3.9.0 lib/bolt/transport/ssh.rb
bolt-3.8.1 lib/bolt/transport/ssh.rb
bolt-3.8.0 lib/bolt/transport/ssh.rb
bolt-3.7.1 lib/bolt/transport/ssh.rb
bolt-3.7.0 lib/bolt/transport/ssh.rb
bolt-3.6.1 lib/bolt/transport/ssh.rb
bolt-3.6.0 lib/bolt/transport/ssh.rb
bolt-3.5.0 lib/bolt/transport/ssh.rb
bolt-3.4.0 lib/bolt/transport/ssh.rb