[DRE-commits] [vagrant-libvirt] 06/77: Using ssh info directly without shelling out
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:56:32 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.17
in repository vagrant-libvirt.
commit 67eae75c9878d323b847e59282d0ed0ab7275872
Author: Ben Keith <keitwb at gmail.com>
Date: Fri Feb 7 09:42:08 2014 -0500
Using ssh info directly without shelling out
- The `vagrant ssh_config` command was including the `Host` option, which for
OpenSSH_6.5p1 at least is throwing an error:
```
Host directive not supported as a command-line option
```
- Also changing the local bind_address in the ssh command to 'localhost'
instead of '0.0.0.0' in order to not expose the VM to other hosts on the host
machine's network. If this is desired, then the user can manually override
it in the Vagrantfile config for port forwarding.
---
lib/vagrant-libvirt/action/forward_ports.rb | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/lib/vagrant-libvirt/action/forward_ports.rb b/lib/vagrant-libvirt/action/forward_ports.rb
index f976361..55a0677 100644
--- a/lib/vagrant-libvirt/action/forward_ports.rb
+++ b/lib/vagrant-libvirt/action/forward_ports.rb
@@ -47,8 +47,8 @@ module VagrantPlugins
))
ssh_pid = redirect_port(
- @env[:machine].name,
- fp[:host_ip] || '0.0.0.0',
+ @env[:machine],
+ fp[:host_ip] || 'localhost',
fp[:host],
fp[:guest_ip] || @env[:machine].provider.ssh_info[:host],
fp[:guest]
@@ -77,13 +77,24 @@ module VagrantPlugins
end
def redirect_port(machine, host_ip, host_port, guest_ip, guest_port)
+ ssh_info = machine.ssh_info
params = %W(
- #{machine}
- -L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}
+ "-L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}"
-N
+ #{ssh_info[:host]}
).join(' ')
- # TODO get options without shelling out
- options = `vagrant ssh-config #{machine} | awk '{printf " -o "$1"="$2}'`
+
+ options = (%W(
+ User=#{ssh_info[:username]}
+ Port=#{ssh_info[:port]}
+ UserKnownHostsFile=/dev/null
+ StrictHostKeyChecking=no
+ PasswordAuthentication=no
+ ForwardX11=#{ssh_info[:forward_x11] ? 'yes' : 'no'}
+ ) + ssh_info[:private_key_path].map do |pk|
+ "IdentityFile=#{pk}"
+ end).map { |s| s.prepend('-o ') }.join(' ')
+
ssh_cmd = "ssh #{options} #{params}"
@logger.debug "Forwarding port with `#{ssh_cmd}`"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git
More information about the Pkg-ruby-extras-commits
mailing list