lib/vagrant-unison2/ssh_command.rb in vagrant-unison2-1.2.4 vs lib/vagrant-unison2/ssh_command.rb in vagrant-unison2-2.0.0
- old
+ new
@@ -17,12 +17,11 @@
%W(
-p #{@machine.config.unison.ssh_port}
#{proxy_command}
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
- -o IdentitiesOnly=yes
- #{key_paths}
+ #{identity}
).compact.join(' ')
end
def uri(unison_paths)
username = @machine.config.unison.ssh_user
@@ -37,11 +36,19 @@
command = @machine.ssh_info[:proxy_command]
return nil unless command
"-o ProxyCommand='#{command}'"
end
+ def identity
+ if @machine.config.unison.ssh_use_agent
+ ''
+ else
+ (%w(-o IdentitiesOnly=yes) << key_paths).join(' ')
+ end
+ end
+
def key_paths
- @machine.ssh_info[:private_key_path].map { |p| "-i #{p}" }.join(' ')
+ @machine.ssh_info[:private_key_path].map { |p| "-i #{p.shellescape}" }.join(' ')
end
end
end
end