diff --git a/CHANGELOG.md b/CHANGELOG.md index 94183c187..c8f6ae01a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ BUG FIXES: - core: box removal of a V1 box works - core: `vagrant ssh -c` commands are now executed in the context of a login shell (regression). [GH-2636] + - core: specifying `-t` or `-T` to `vagrant ssh -c` as extra args + will properly enable/disable a TTY for OpenSSH. [GH-2618] - guests/debian: fix `use_dhcp_assigned_default_route` to work properly. [GH-2648] - guests/debian,ubuntu: fix change\_host\_name for FQDNs with trailing diff --git a/lib/vagrant/action/builtin/ssh_run.rb b/lib/vagrant/action/builtin/ssh_run.rb index afa8253ec..4e714837c 100644 --- a/lib/vagrant/action/builtin/ssh_run.rb +++ b/lib/vagrant/action/builtin/ssh_run.rb @@ -41,7 +41,14 @@ module Vagrant # Execute! opts = env[:ssh_opts] || {} - opts[:extra_args] = ["-t", command] + + # Allow the user to specify a tty or non-tty manually, but if they + # don't then we default to a TTY + if !opts[:extra_args].include?("-t") && !opts[:extra_args].include?("-T") + opts[:extra_args] << "-t" + end + + opts[:extra_args] << command opts[:subprocess] = true env[:ssh_run_exit_status] = Util::SSH.exec(info, opts) diff --git a/plugins/commands/ssh/command.rb b/plugins/commands/ssh/command.rb index 276093395..e393f6898 100644 --- a/plugins/commands/ssh/command.rb +++ b/plugins/commands/ssh/command.rb @@ -38,20 +38,22 @@ module VagrantPlugins # Execute the actual SSH with_target_vms(argv, :single_target => true) do |vm| + ssh_opts = { + :plain_mode => options[:plain_mode], + :extra_args => options[:ssh_args] + } + if options[:command] @logger.debug("Executing single command on remote machine: #{options[:command]}") - env = vm.action(:ssh_run, :ssh_run_command => options[:command]) + env = vm.action(:ssh_run, + ssh_opts: ssh_opts, + ssh_run_command: options[:command],) # Exit with the exit status of the command or a 0 if we didn't # get one. exit_status = env[:ssh_run_exit_status] || 0 return exit_status else - opts = { - :plain_mode => options[:plain_mode], - :extra_args => options[:ssh_args] - } - @logger.debug("Invoking `ssh` action on machine") vm.action(:ssh, :ssh_opts => opts)