Raise proper exception if SSH connection is refused with message to help people.

This commit is contained in:
Mitchell Hashimoto 2010-09-14 15:00:46 -06:00
parent 036edfcc2a
commit 759bbd046b
3 changed files with 15 additions and 1 deletions

View File

@ -199,6 +199,11 @@ module Vagrant
error_key(:ssh_authentication_failed)
end
class SSHConnectionRefused < VagrantError
status_code(43)
error_key(:ssh_connection_refused)
end
class SSHKeyBadPermissions < VagrantError
status_code(12)
error_key(:ssh_key_bad_permissions)

View File

@ -70,6 +70,8 @@ module Vagrant
yield SSH::Session.new(ssh)
end
end
rescue Errno::ECONNREFUSED
raise Errors::SSHConnectionRefused.new
end
# Uploads a file from `from` to `to`. `from` is expected to be a filename
@ -94,7 +96,7 @@ module Vagrant
execute(:timeout => env.config.ssh.timeout) do |ssh|
Thread.current[:result] = true
end
rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
rescue Errno::ECONNREFUSED, Net::SSH::Disconnect, Errors::SSHConnectionRefused
# False, its defaulted above
end
end

View File

@ -27,6 +27,13 @@ en:
Vagrant assumes that this means the command failed!
%{command}
ssh_connection_refused: |-
SSH connection was refused! This usually happens if the VM failed to
boot properly. Some steps to try to fix this: First, try reloading your
VM with `vagrant reload`, since a simple restart sometimes fixes things.
If that doesn't work, destroy your VM and recreate it with a `vagrant destroy`
followed by a `vagrant up`. If that doesn't work, contact a Vagrant
maintainer (support channels listed on the website) for more assistance.
ssh_key_bad_permissions: |-
The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will