From dd69de1073067f95279a14f4aeea3204869dbf90 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 Jul 2015 16:05:23 -0600 Subject: [PATCH] communicators/ssh: only try auth methods that are valid --- plugins/communicators/ssh/communicator.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 4109a66ff..c3fb3adf7 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -322,9 +322,15 @@ module VagrantPlugins # Default some options opts[:retries] = 5 if !opts.key?(:retries) + # Set some valid auth methods. We disable the auth methods that + # we're not using if we don't have the right auth info. + auth_methods = ["none", "hostbased"] + auth_methods << "publickey" if ssh_info[:private_key_path] + auth_methods << "password" if ssh_info[:password] + # Build the options we'll use to initiate the connection via Net::SSH common_connect_opts = { - auth_methods: ["none", "publickey", "hostbased", "password"], + auth_methods: auth_methods, config: false, forward_agent: ssh_info[:forward_agent], keys: ssh_info[:private_key_path], @@ -439,7 +445,7 @@ module VagrantPlugins def shell_cmd(opts) sudo = opts[:sudo] shell = opts[:shell] - + # Determine the shell to execute. Prefer the explicitly passed in shell # over the default configured shell. If we are using `sudo` then we # need to wrap the shell in a `sudo` call.