lib/veewee/provider/core/box/ssh.rb in veewee-0.3.12 vs lib/veewee/provider/core/box/ssh.rb in veewee-0.4.0

- old
+ new

@@ -1,6 +1,7 @@ require 'veewee/provider/core/helper/ssh' +require 'shellwords' module Veewee module Provider module Core module BoxCommand @@ -10,15 +11,12 @@ raise Veewee::Error,"Box is not running" unless self.running? host_ip=self.ip_address if (options[:interactive]==true) - # Command line options - extended_command="#{command}" - unless host_ip.nil? || host_ip=="" - ssh_command="ssh #{ssh_commandline_options(options)} #{host_ip} \"#{extended_command}\"" + ssh_command="ssh #{ssh_commandline_options(options)} #{host_ip} #{Shellwords.escape command}" fg_exec(ssh_command,options) else ui.error("Can't ssh into '#{@name} as we couldn't figure out it's ip-address",:prefix => false) @@ -40,11 +38,13 @@ "-o UserKnownHostsFile=/dev/null", "-t -o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes", "-o VerifyHostKeyDNS=no" ] - if !(definition.ssh_key.nil? || definition.ssh_key.length!="") - command_options << "-i #{definition.ssh_key}" + if !(definition.ssh_key.nil? || definition.ssh_key.empty?) + # Filenames of SSH keys are relative to their definition + ssh_key = File.join(definition.path, definition.ssh_key) + command_options << "-i #{ssh_key}" end commandline_options="#{command_options.join(" ")} ".strip user_option=definition.ssh_user.nil? ? "" : "-l #{definition.ssh_user}"