Add X11 ssh forwarding option (off by default).

This commit is contained in:
Petyo Ivanov 2011-01-01 18:43:16 +01:00 committed by Mitchell Hashimoto
parent e0c716e454
commit b9e24090e9
4 changed files with 14 additions and 0 deletions

View File

@ -12,6 +12,7 @@ Vagrant::Config.run do |config|
config.ssh.timeout = 30
config.ssh.private_key_path = File.expand_path("keys/vagrant", Vagrant.source_root)
config.ssh.forward_agent = false
config.ssh.forward_x11 = false
config.vm.auto_port_range = (2200..2250)
config.vm.box_ovf = "box.ovf"

View File

@ -11,6 +11,7 @@ module Vagrant
attr_accessor :timeout
attr_writer :private_key_path
attr_accessor :forward_agent
attr_accessor :forward_x11
def private_key_path
File.expand_path(@private_key_path, env.root_path)

View File

@ -42,6 +42,7 @@ module Vagrant
"-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes",
"-i #{options[:private_key_path]}"]
command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent
command_options << "-o ForwardX11=yes" if env.config.ssh.forward_x11
# Some hackery going on here. On Mac OS X Leopard (10.5), exec fails
# (GH-51). As a workaround, we fork and wait. On all other platforms,

View File

@ -69,6 +69,17 @@ class SshTest < Test::Unit::TestCase
@ssh.connect
end
should "add forward X11 option if enabled" do
@env.config.ssh.forward_x11 = true
ssh_exec_expect(@ssh.port,
@env.config.ssh.private_key_path,
@env.config.ssh.username,
@env.config.ssh.host) do |args|
assert args =~ /-o ForwardX11=yes/
end
@ssh.connect
end
context "on leopard" do
setup do
Vagrant::Util::Platform.stubs(:leopard?).returns(true)