diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 450e21fc1..c4fc253d1 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -452,9 +452,11 @@ module Vagrant info[:keys_only] ||= @config.ssh.default.keys_only info[:verify_host_key] ||= @config.ssh.default.verify_host_key info[:username] ||= @config.ssh.default.username + info[:remote_user] ||= @config.ssh.default.remote_user info[:compression] ||= @config.ssh.default.compression info[:dsa_authentication] ||= @config.ssh.default.dsa_authentication info[:extra_args] ||= @config.ssh.default.extra_args + info[:config] ||= @config.ssh.default.config # We set overrides if they are set. These take precedence over # provider-returned data. @@ -466,7 +468,9 @@ module Vagrant info[:dsa_authentication] = @config.ssh.dsa_authentication info[:username] = @config.ssh.username if @config.ssh.username info[:password] = @config.ssh.password if @config.ssh.password + info[:remote_user] = @config.ssh.remote_user if @config.ssh.remote_user info[:extra_args] = @config.ssh.extra_args if @config.ssh.extra_args + info[:config] = @config.ssh.config if @config.ssh.config # We also set some fields that are purely controlled by Vagrant info[:forward_agent] = @config.ssh.forward_agent diff --git a/plugins/commands/ssh_config/command.rb b/plugins/commands/ssh_config/command.rb index 492352f36..c21a9aec7 100644 --- a/plugins/commands/ssh_config/command.rb +++ b/plugins/commands/ssh_config/command.rb @@ -55,6 +55,8 @@ module VagrantPlugins proxy_command: ssh_info[:proxy_command], ssh_command: ssh_info[:ssh_command], forward_env: ssh_info[:forward_env], + config: ssh_info[:config], + remote_user: ssh_info[:remote_user], } # Render the template and output directly to STDOUT diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 4e7ab4d51..c92e39980 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -418,6 +418,10 @@ module VagrantPlugins connect_opts[:config] = ssh_info[:config] end + if ssh_info[:remote_user] + connect_opts[:remote_user] = ssh_info[:remote_user] + end + @logger.info("Attempting to connect to SSH...") @logger.info(" - Host: #{ssh_info[:host]}") @logger.info(" - Port: #{ssh_info[:port]}") diff --git a/plugins/kernel_v2/config/ssh_connect.rb b/plugins/kernel_v2/config/ssh_connect.rb index c4c6fec0e..9e8666d38 100644 --- a/plugins/kernel_v2/config/ssh_connect.rb +++ b/plugins/kernel_v2/config/ssh_connect.rb @@ -3,6 +3,7 @@ module VagrantPlugins class SSHConnectConfig < Vagrant.plugin("2", :config) attr_accessor :host attr_accessor :port + attr_accessor :config attr_accessor :private_key_path attr_accessor :username attr_accessor :password @@ -13,10 +14,12 @@ module VagrantPlugins attr_accessor :compression attr_accessor :dsa_authentication attr_accessor :extra_args + attr_accessor :remote_user def initialize @host = UNSET_VALUE @port = UNSET_VALUE + @config = UNSET_VALUE @private_key_path = UNSET_VALUE @username = UNSET_VALUE @password = UNSET_VALUE @@ -27,6 +30,7 @@ module VagrantPlugins @compression = UNSET_VALUE @dsa_authentication = UNSET_VALUE @extra_args = UNSET_VALUE + @remote_user = UNSET_VALUE end def finalize! @@ -42,6 +46,7 @@ module VagrantPlugins @compression = true if @compression == UNSET_VALUE @dsa_authentication = true if @dsa_authentication == UNSET_VALUE @extra_args = nil if @extra_args == UNSET_VALUE + @remote_user = nil if @remote_user == UNSET_VALUE if @private_key_path && !@private_key_path.is_a?(Array) @private_key_path = [@private_key_path] @@ -51,6 +56,9 @@ module VagrantPlugins @verify_host_key = @paranoid end + # Default to not loading system ssh_config file + @config = false if @config == UNSET_VALUE + # Values for verify_host_key changed in 5.0.0 of net-ssh. If old value # detected, update with new value case @verify_host_key