Detect PuTTY Link on Windows and show error [GH-1518]

This commit is contained in:
Mitchell Hashimoto 2013-04-06 16:50:59 -07:00
parent 0874d4a77a
commit 868f8d4061
4 changed files with 31 additions and 1 deletions

View File

@ -40,6 +40,7 @@ IMPROVEMENTS:
- Specify the default provider with the `VAGRANT_DEFAULT_PROVIDER`
environmental variable. [GH-1478]
- Invalid settings are now caught and shown in a user-friendly way. [GH-1484]
- Detect PuTTY Link SSH client on Windows and show an error. [GH-1518]
BUG FIXES:

View File

@ -411,6 +411,10 @@ module Vagrant
error_key(:ssh_host_down)
end
class SSHIsPuttyLink < VagrantError
error_key(:ssh_is_putty_link)
end
class SSHKeyBadOwner < VagrantError
error_key(:ssh_key_bad_owner)
end

View File

@ -3,6 +3,7 @@ require "log4r"
require "vagrant/util/file_mode"
require "vagrant/util/platform"
require "vagrant/util/safe_exec"
require "vagrant/util/subprocess"
require "vagrant/util/which"
module Vagrant
@ -60,7 +61,8 @@ module Vagrant
def self.exec(ssh_info, opts={})
# Ensure the platform supports ssh. On Windows there are several programs which
# include ssh, notably git, mingw and cygwin, but make sure ssh is in the path!
if !Which.which("ssh")
ssh_path = Which.which("ssh")
if !ssh_path
if Platform.windows?
raise Errors::SSHUnavailableWindows,
:host => ssh_info[:host],
@ -72,6 +74,19 @@ module Vagrant
raise Errors::SSHUnavailable
end
# On Windows, we need to detect whether SSH is actually "plink"
# underneath the covers. In this case, we tell the user.
if Platform.windows?
r = Subprocess.execute(ssh_path)
if r.stdout.include?("PuTTY Link")
raise Errors::SSHIsPuttyLink,
:host => ssh_info[:host],
:port => ssh_info[:port],
:username => ssh_info[:username],
:key_path => ssh_info[:private_key_path]
end
end
# If plain mode is enabled then we don't do any authentication (we don't
# set a user or an identity file)
plain_mode = opts[:plain_mode]

View File

@ -364,6 +364,16 @@ en:
While attempting to connect with SSH, a "host is down" (EHOSTDOWN)
error was received. Please verify your SSH settings are correct
and try again.
ssh_is_putty_link: |-
The `ssh` executable found in the PATH is a PuTTY Link SSH client.
Vagrant is only compatible with OpenSSH SSH clients. Please install
an OpenSSH SSH client or manually SSH in using your existing client
using the information below.
Host: %{host}
Port: %{port}
Username: %{username}
Private key: %{key_path}
ssh_key_bad_owner: |-
The private key to connect to the machine via SSH must be owned
by the user running Vagrant. This is a strict requirement from