ssh-config now uses the new ssh_info method

This commit is contained in:
Mitchell Hashimoto 2012-01-06 17:33:02 -08:00
parent 7ed9f8bd73
commit 3ffa533011
2 changed files with 14 additions and 12 deletions

View File

@ -23,19 +23,19 @@ module Vagrant
raise Errors::VMNotCreatedError if !vm.created? raise Errors::VMNotCreatedError if !vm.created?
raise Errors::VMInaccessible if !vm.state == :inaccessible raise Errors::VMInaccessible if !vm.state == :inaccessible
# We need to fix the file permissions of the key if they aren't set ssh_info = vm.ssh_info
# properly, otherwise if the user attempts to SSH in, it won't work! variables = {
vm.ssh.check_key_permissions(vm.ssh.private_key_path)
$stdout.puts(Util::TemplateRenderer.render("ssh_config", {
:host_key => options[:host] || vm.name || "vagrant", :host_key => options[:host] || vm.name || "vagrant",
:ssh_host => vm.config.ssh.host, :ssh_host => ssh_info[:host],
:ssh_user => vm.config.ssh.username, :ssh_port => ssh_info[:port],
:ssh_port => vm.ssh.port, :ssh_user => ssh_info[:username],
:private_key_path => vm.ssh.private_key_path, :private_key_path => ssh_info[:private_key_path],
:forward_agent => vm.config.ssh.forward_agent, :forward_agent => ssh_info[:forward_agent],
:forward_x11 => vm.config.ssh.forward_x11 :forward_x11 => ssh_info[:forward_x11]
})) }
# Render the template and output directly to STDOUT
$stdout.puts(Util::TemplateRenderer.render("ssh_config", variables)
end end
end end
end end

View File

@ -96,6 +96,8 @@ module Vagrant
pk_path = config.ssh.private_key_path || env.default_private_key_path pk_path = config.ssh.private_key_path || env.default_private_key_path
results[:private_key_path] = File.expand_path(pk_path, env.root_path) results[:private_key_path] = File.expand_path(pk_path, env.root_path)
# TODO: Check and fix key permissions
# Return the results # Return the results
return results return results
end end