lib/veewee/provider/core/box/ssh.rb in veewee-0.4.0 vs lib/veewee/provider/core/box/ssh.rb in veewee-0.4.1
- old
+ new
@@ -1,13 +1,14 @@
require 'veewee/provider/core/helper/ssh'
require 'shellwords'
+require 'pathname'
+
module Veewee
module Provider
module Core
module BoxCommand
-
def ssh(command=nil,options={})
raise Veewee::Error,"Box is not running" unless self.running?
host_ip=self.ip_address
@@ -21,11 +22,12 @@
else
ui.error("Can't ssh into '#{@name} as we couldn't figure out it's ip-address",:prefix => false)
end
else
ssh_options={:user => definition.ssh_user,:password => definition.ssh_password, :port => definition.ssh_host_port}
- ssh_execute(host_ip,command,ssh_options)
+ ssh_options[:keys] = ssh_key_to_a(definition.ssh_key) if definition.ssh_key
+ ssh_execute(host_ip, command, ssh_options)
end
end
private
@@ -35,16 +37,20 @@
#"-q", #Suppress warning messages
# "-T", #Pseudo-terminal will not be allocated because stdin is not a terminal.
"-p #{ssh_options[:port]}",
"-o UserKnownHostsFile=/dev/null",
"-t -o StrictHostKeyChecking=no",
- "-o IdentitiesOnly=yes",
"-o VerifyHostKeyDNS=no"
]
- 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}"
+ if definition.ssh_key
+ command_options << "-o IdentitiesOnly=yes"
+ ssh_keys = ssh_key_to_a(ssh_key)
+ ssh_keys.each do |ssh_keys|
+ # Filenames of SSH keys are relative to their definition
+ ssh_key = Pathname.new(definition.ssh_key)
+ ssh_key = File.join(definition.path, ssh_key) if ssh_key.relative?
+ command_options << "-i #{ssh_key}"
+ end
end
commandline_options="#{command_options.join(" ")} ".strip
user_option=definition.ssh_user.nil? ? "" : "-l #{definition.ssh_user}"