From bab369e856f37e92bb5f77fd0920ab178bca75e2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 27 Aug 2010 00:01:27 -0700 Subject: [PATCH] SSHAuthenticationFailed error --- lib/vagrant/errors.rb | 5 +++++ lib/vagrant/ssh.rb | 2 +- templates/locales/en.yml | 5 +++++ templates/strings.yml | 15 --------------- test/vagrant/ssh_test.rb | 3 +-- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 765a77da3..04e1d97fa 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -56,6 +56,11 @@ module Vagrant error_key(:no_env) end + class SSHAuthenticationFailed < VagrantError + status_code(11) + error_key(:ssh_authentication_failed) + end + class SSHUnavailableWindows < VagrantError status_code(10) error_key(:ssh_unavailable_windows) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index d12565327..6220faee9 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -105,7 +105,7 @@ module Vagrant check_thread.join(env.config.ssh.timeout) return check_thread[:result] rescue Net::SSH::AuthenticationFailed - error_and_exit(:vm_ssh_auth_failed) + raise Errors::SSHAuthenticationFailed.new end # Checks the file permissions for the private key, resetting them diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 2ed158fc0..3b46bb846 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -11,6 +11,11 @@ en: multi_vm_required: A multi-vm environment is required for name specification to this command. multi_vm_target_required: `vagrant %{command}` requires a specific VM name to target in a multi-VM environment. no_env: No Vagrant environment detected. Run `vagrant init` to set one up. + ssh_authentication_failed: |- + SSH authentication failed! This is typically caused by the public/private + keypair for the SSH user not being properly set on the guest VM. Please + verify that the guest VM is setup with the proper public key, and that + the private key path for Vagrant is setup propery as well. ssh_unavailable_windows: |- `vagrant ssh` isn't available on the Windows platform. The vagrant.ppk file for use with Putty is available at: diff --git a/templates/strings.yml b/templates/strings.yml index b49f8fc6b..a2660a57e 100644 --- a/templates/strings.yml +++ b/templates/strings.yml @@ -200,21 +200,6 @@ The vagrant virtual environment you are trying to package must be powered off. :vm_mount_fail: |- Failed to mount shared folders. vboxsf was not available. -:vm_ssh_auth_failed: |- - SSH authentication failed! While this could be due to a variety of reasons, - the two most common are: private key path is incorrect or you're using a box - which was built for Vagrant 0.1.x. - - Vagrant 0.2.x dropped support for password-based authentication. If you're - tring to `vagrant up` a box which does not support Vagrant's private/public - keypair, then this error will be raised. To resolve this, read the guide - on converting base boxes from password-based to keypairs here: - - http://vagrantup.com/docs/converting_password_to_key_ssh.html - - If the box was built for 0.2.x and contains a custom public key, perhaps - the path to the private key is incorrect. Check your `config.ssh.private_key_path`. - #--------------------------------------------------------------------- # CATEGORY: Error Messages for Linux System #--------------------------------------------------------------------- diff --git a/test/vagrant/ssh_test.rb b/test/vagrant/ssh_test.rb index 223ce12c9..ff5085833 100644 --- a/test/vagrant/ssh_test.rb +++ b/test/vagrant/ssh_test.rb @@ -229,8 +229,7 @@ class SshTest < Test::Unit::TestCase should "error and exit if a Net::SSH::AuthenticationFailed is raised" do @ssh.expects(:execute).raises(Net::SSH::AuthenticationFailed) - @ssh.expects(:error_and_exit).with(:vm_ssh_auth_failed).once - @ssh.up? + assert_raises(Vagrant::Errors::SSHAuthenticationFailed) { @ssh.up? } end end