From 00c9f2c973382fd77acd2a4b054e98fae2a506c9 Mon Sep 17 00:00:00 2001 From: Matt Wormley Date: Wed, 3 Apr 2013 13:54:21 -0700 Subject: [PATCH] added ssh.proxy_command to handle waiting for aws ssh connection when ssh proxy in place. use config.ssh.proxy_command = "ssh -q @ nc %h %p" --- lib/vagrant/machine.rb | 3 +++ plugins/communicators/ssh/communicator.rb | 2 ++ plugins/kernel_v2/config/ssh.rb | 1 + 3 files changed, 6 insertions(+) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index f8be78aef..dda3aebda 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -281,6 +281,9 @@ module Vagrant info[:forward_agent] = @config.ssh.forward_agent info[:forward_x11] = @config.ssh.forward_x11 + # add in provided proxy command config + info[:proxy_command] = @config.ssh.proxy_command if @config.ssh.proxy_command + # Set the private key path. If a specific private key is given in # the Vagrantfile we set that. Otherwise, we use the default (insecure) # private key, but only if the provider didn't give us one. diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 852034d74..b17a8770d 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -5,6 +5,7 @@ require 'timeout' require 'log4r' require 'net/ssh' +require 'net/ssh/proxy/command' require 'net/scp' require 'vagrant/util/ansi_escape_code_remover' @@ -193,6 +194,7 @@ module VagrantPlugins :logger => ssh_logger, :verbose => :debug }) + connect_opts[:proxy] = Net::SSH::Proxy::Command.new(ssh_info[:proxy_command]) if ssh_info[:proxy_command] @logger.info("Attempting to connect to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}") Net::SSH.start(ssh_info[:host], ssh_info[:username], connect_opts) diff --git a/plugins/kernel_v2/config/ssh.rb b/plugins/kernel_v2/config/ssh.rb index 689a2ea5c..7242d3db0 100644 --- a/plugins/kernel_v2/config/ssh.rb +++ b/plugins/kernel_v2/config/ssh.rb @@ -13,6 +13,7 @@ module VagrantPlugins attr_accessor :forward_agent attr_accessor :forward_x11 attr_accessor :shell + attr_accessor :proxy_command def validate(machine) errors = []