Merge pull request #4905 from mitchellh/gc-fix-docker-agent-forwarding
providers/docker: fix support of agent forwarding
This commit is contained in:
commit
e212b31394
|
@ -93,6 +93,7 @@ BUG FIXES:
|
||||||
- providers/docker: Fix issue where multiple identical proxy VMs would
|
- providers/docker: Fix issue where multiple identical proxy VMs would
|
||||||
be created. [GH-3963]
|
be created. [GH-3963]
|
||||||
- providers/docker: Multiple links with the same name work. [GH-4571]
|
- providers/docker: Multiple links with the same name work. [GH-4571]
|
||||||
|
- providers/docker: Add support of SSH agent forwarding. [GH-4905]
|
||||||
- providers/virtualbox: Show a human-friendly error if VirtualBox didn't
|
- providers/virtualbox: Show a human-friendly error if VirtualBox didn't
|
||||||
clean up an existing VM. [GH-4681]
|
clean up an existing VM. [GH-4681]
|
||||||
- providers/virtualbox: Detect case when VirtualBox reports 0.0.0.0 as
|
- providers/virtualbox: Detect case when VirtualBox reports 0.0.0.0 as
|
||||||
|
|
|
@ -19,14 +19,19 @@ module VagrantPlugins
|
||||||
# Modify the SSH options for when we `vagrant ssh`...
|
# Modify the SSH options for when we `vagrant ssh`...
|
||||||
ssh_opts = env[:ssh_opts] || {}
|
ssh_opts = env[:ssh_opts] || {}
|
||||||
|
|
||||||
# Build the command we'll execute within the host machine
|
# Build the command we'll execute within the Docker host machine:
|
||||||
ssh_command = env[:machine].communicate.container_ssh_command
|
ssh_command = env[:machine].communicate.container_ssh_command
|
||||||
if !Array(ssh_opts[:extra_args]).empty?
|
if !Array(ssh_opts[:extra_args]).empty?
|
||||||
ssh_command << " #{Array(ssh_opts[:extra_args]).join(" ")}"
|
ssh_command << " #{Array(ssh_opts[:extra_args]).join(" ")}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Modify the SSH options for the original command:
|
||||||
# Append "-t" to force a TTY allocation
|
# Append "-t" to force a TTY allocation
|
||||||
ssh_opts[:extra_args] = ["-t"]
|
ssh_opts[:extra_args] = ["-t"]
|
||||||
|
# Enable Agent forwarding when requested for the target VM
|
||||||
|
if env[:machine].ssh_info[:forward_agent]
|
||||||
|
ssh_opts[:extra_args] << "-o ForwardAgent=yes"
|
||||||
|
end
|
||||||
ssh_opts[:extra_args] << ssh_command
|
ssh_opts[:extra_args] << ssh_command
|
||||||
|
|
||||||
# Set the opts
|
# Set the opts
|
||||||
|
|
|
@ -137,18 +137,21 @@ module VagrantPlugins
|
||||||
info[:port] ||= 22
|
info[:port] ||= 22
|
||||||
|
|
||||||
# Make sure our private keys are synced over to the host VM
|
# Make sure our private keys are synced over to the host VM
|
||||||
key_args = sync_private_keys(info).map do |path|
|
ssh_args = sync_private_keys(info).map do |path|
|
||||||
"-i #{path}"
|
"-i #{path}"
|
||||||
end.join(" ")
|
end
|
||||||
|
|
||||||
|
# Use ad-hoc SSH options for the hop on the docker proxy
|
||||||
|
if info[:forward_agent]
|
||||||
|
ssh_args << "-o ForwardAgent=yes"
|
||||||
|
end
|
||||||
|
ssh_args.concat(["-o Compression=yes",
|
||||||
|
"-o ConnectTimeout=5",
|
||||||
|
"-o StrictHostKeyChecking=no",
|
||||||
|
"-o UserKnownHostsFile=/dev/null"])
|
||||||
|
|
||||||
# Build the SSH command
|
# Build the SSH command
|
||||||
"ssh #{key_args} " +
|
"ssh #{info[:username]}@#{info[:host]} -p#{info[:port]} #{ssh_args.join(" ")}"
|
||||||
"-o Compression=yes " +
|
|
||||||
"-o ConnectTimeout=5 " +
|
|
||||||
"-o StrictHostKeyChecking=no " +
|
|
||||||
"-o UserKnownHostsFile=/dev/null " +
|
|
||||||
"-p#{info[:port]} " +
|
|
||||||
"#{info[:username]}@#{info[:host]}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
Loading…
Reference in New Issue