Nicer error for unsupported SSH key type [GH-805]
This commit is contained in:
parent
0245245daa
commit
3ff4be3632
|
@ -2,6 +2,7 @@
|
|||
|
||||
- Provisioners will still mount folders and such if `--no-provision` is
|
||||
used, so that `vagrant provision` works. [GH-803]
|
||||
- Nicer error message if an unsupported SSH key type is used. [GH-805]
|
||||
|
||||
## 1.0.1 (March 11, 2012)
|
||||
|
||||
|
|
|
@ -129,10 +129,24 @@ module Vagrant
|
|||
@vm.ssh.check_key_permissions(ssh_info[:private_key_path])
|
||||
|
||||
# Connect to SSH, giving it a few tries
|
||||
@logger.info("Connecting to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}")
|
||||
exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect]
|
||||
connection = retryable(:tries => @vm.config.ssh.max_tries, :on => exceptions) do
|
||||
Net::SSH.start(ssh_info[:host], ssh_info[:username], opts)
|
||||
connection = nil
|
||||
begin
|
||||
@logger.info("Connecting to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}")
|
||||
exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect]
|
||||
connection = retryable(:tries => @vm.config.ssh.max_tries, :on => exceptions) do
|
||||
Net::SSH.start(ssh_info[:host], ssh_info[:username], opts)
|
||||
end
|
||||
rescue Net::SSH::AuthenticationFailed
|
||||
# This happens if authentication failed. We wrap the error in our
|
||||
# own exception.
|
||||
raise Errors::SSHAuthenticationFailed
|
||||
rescue Errno::ECONNREFUSED
|
||||
# This is raised if we failed to connect the max amount of times
|
||||
raise Errors::SSHConnectionRefused
|
||||
rescue NotImplementedError
|
||||
# This is raised if a private key type that Net-SSH doesn't support
|
||||
# is used. Show a nicer error.
|
||||
raise Errors::SSHKeyTypeNotSupported
|
||||
end
|
||||
|
||||
@connection = connection
|
||||
|
@ -145,14 +159,7 @@ module Vagrant
|
|||
# Yield the connection that is ready to be used and
|
||||
# return the value of the block
|
||||
return yield connection if block_given?
|
||||
rescue Net::SSH::AuthenticationFailed
|
||||
# This happens if authentication failed. We wrap the error in our
|
||||
# own exception.
|
||||
raise Errors::SSHAuthenticationFailed
|
||||
rescue Errno::ECONNREFUSED
|
||||
# This is raised if we failed to connect the max amount of times
|
||||
raise Errors::SSHConnectionRefused
|
||||
end
|
||||
end
|
||||
|
||||
# Executes the command on an SSH connection within a login shell.
|
||||
def shell_execute(connection, command, sudo=false)
|
||||
|
|
|
@ -318,6 +318,11 @@ module Vagrant
|
|||
error_key(:ssh_key_bad_permissions)
|
||||
end
|
||||
|
||||
class SSHKeyTypeNotSupported < VagrantError
|
||||
status_code(76)
|
||||
error_key(:ssh_key_type_not_supported)
|
||||
end
|
||||
|
||||
class SSHPortNotDetected < VagrantError
|
||||
status_code(50)
|
||||
error_key(:ssh_port_not_detected)
|
||||
|
|
|
@ -124,6 +124,10 @@ en:
|
|||
permissions on the following file to 0600 and then try running this command again:
|
||||
|
||||
%{key_path}
|
||||
ssh_key_type_not_supported: |-
|
||||
The private key you're attempting to use with this Vagrant box uses
|
||||
an unsupported encryption type. The SSH library Vagrant uses does not support
|
||||
this key type. Please use `ssh-rsa` or `ssh-dss` instead.
|
||||
ssh_port_not_detected: |-
|
||||
Vagrant couldn't determine the SSH port for your VM! Vagrant attempts to
|
||||
automatically find a forwarded port that matches your `config.ssh.guest_port`
|
||||
|
|
Loading…
Reference in New Issue