Sha256: f7b24aafc942b7e9f2fdfab137d8f46e101c4f6d83c8e0f10a09a2edcf4f70f8

Contents?: true

Size: 1.28 KB

Versions: 62

Compression:

Stored size: 1.28 KB

Contents

require "pathname"

require "vagrant/util/ssh"

module Vagrant
  module Action
    module Builtin
      # This class will exec into a full fledged SSH console into the
      # remote machine. This middleware assumes that the VM is running and
      # ready for SSH, and uses the {Machine#ssh_info} method to retrieve
      # SSH information necessary to connect.
      #
      # Note: If there are any middleware after `SSHExec`, they will **not**
      # run, since exec replaces the currently running process.
      class SSHExec
        # For quick access to the `SSH` class.
        include Vagrant::Util

        def initialize(app, env)
          @app = app
        end

        def call(env)
          # Grab the SSH info from the machine or the environment
          info = env[:ssh_info]
          info ||= env[:machine].ssh_info

          # If the result is nil, then the machine is telling us that it is
          # not yet ready for SSH, so we raise this exception.
          raise Errors::SSHNotReady if info.nil?

          info[:private_key_path] ||= []

          if info[:private_key_path].empty? && info[:password]
            env[:ui].warn(I18n.t("vagrant.ssh_exec_password"))
          end

          # Exec!
          SSH.exec(info, env[:ssh_opts])
        end
      end
    end
  end
end

Version data entries

62 entries across 55 versions & 7 rubygems

Version Path
vagrant-unbundled-1.9.8.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.9.7.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.9.5.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.9.1.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.5.2 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.5.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.4.2 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.4.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.1.2 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-unbundled-1.8.1.1 lib/vagrant/action/builtin/ssh_exec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/lib/vagrant/action/builtin/ssh_exec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/lib/vagrant/action/builtin/ssh_exec.rb