Options after `--` to `vagrant ssh` are passed through to ssh [GH-554]
This commit is contained in:
parent
1f02318a5e
commit
8cc162f48f
|
@ -43,6 +43,8 @@
|
||||||
by shortcut. [GH-367]
|
by shortcut. [GH-367]
|
||||||
- Arbitrary mount options can be passed with `:extra` to any shared
|
- Arbitrary mount options can be passed with `:extra` to any shared
|
||||||
folders. [GH-551]
|
folders. [GH-551]
|
||||||
|
- Options passed after a `--` to `vagrant ssh` are now passed directly to
|
||||||
|
`ssh`. [GH-554]
|
||||||
- Removed Thor as a dependency for the command line interfaces. This resulted
|
- Removed Thor as a dependency for the command line interfaces. This resulted
|
||||||
in general speed increases across all command line commands.
|
in general speed increases across all command line commands.
|
||||||
- Linux uses `shutdown -h` instead of `halt` to hopefully more consistently
|
- Linux uses `shutdown -h` instead of `halt` to hopefully more consistently
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: vagrant ssh [vm-name] [-c command]"
|
opts.banner = "Usage: vagrant ssh [vm-name] [-c command] [-- extra ssh args]"
|
||||||
|
|
||||||
opts.separator ""
|
opts.separator ""
|
||||||
|
|
||||||
|
@ -19,9 +19,22 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Parse the options and return if we don't have any target.
|
||||||
argv = parse_options(opts)
|
argv = parse_options(opts)
|
||||||
return if !argv
|
return if !argv
|
||||||
|
|
||||||
|
# Parse out the extra args to send to SSH, which is everything
|
||||||
|
# after the "--"
|
||||||
|
ssh_args = ARGV.drop_while { |i| i != "--" }
|
||||||
|
ssh_args = ssh_args[1..-1]
|
||||||
|
options[:ssh_args] = ssh_args
|
||||||
|
|
||||||
|
# If the remaining arguments ARE the SSH arguments, then just
|
||||||
|
# clear it out. This happens because optparse returns what is
|
||||||
|
# after the "--" as remaining ARGV, and Vagrant can think it is
|
||||||
|
# a multi-vm name (wrong!)
|
||||||
|
argv = [] if argv == ssh_args
|
||||||
|
|
||||||
# Execute the actual SSH
|
# Execute the actual SSH
|
||||||
with_target_vms(argv[0], true) do |vm|
|
with_target_vms(argv[0], true) do |vm|
|
||||||
# Basic checks that are required for proper SSH
|
# Basic checks that are required for proper SSH
|
||||||
|
@ -32,7 +45,12 @@ module Vagrant
|
||||||
if options[:command]
|
if options[:command]
|
||||||
ssh_execute(vm, options[:command])
|
ssh_execute(vm, options[:command])
|
||||||
else
|
else
|
||||||
ssh_connect(vm, { :plain_mode => options[:plain_mode] })
|
opts = {
|
||||||
|
:plain_mode => options[:plain_mode],
|
||||||
|
:extra_args => options[:ssh_args]
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_connect(vm, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,6 +79,9 @@ module Vagrant
|
||||||
command_options << "-i #{options[:private_key_path]}" if !plain_mode
|
command_options << "-i #{options[:private_key_path]}" if !plain_mode
|
||||||
command_options << "-o ForwardAgent=yes" if ssh_info[:forward_agent]
|
command_options << "-o ForwardAgent=yes" if ssh_info[:forward_agent]
|
||||||
|
|
||||||
|
# If there are extra options, then we append those
|
||||||
|
command_options.concat(opts[:extra_args]) if opts[:extra_args]
|
||||||
|
|
||||||
if ssh_info[:forward_x11]
|
if ssh_info[:forward_x11]
|
||||||
# Both are required so that no warnings are shown regarding X11
|
# Both are required so that no warnings are shown regarding X11
|
||||||
command_options << "-o ForwardX11=yes"
|
command_options << "-o ForwardX11=yes"
|
||||||
|
|
Loading…
Reference in New Issue