diff --git a/CHANGELOG.md b/CHANGELOG.md index 14405c7b8..deaba670b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index beef04c79..fa5cd4131 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -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 diff --git a/lib/vagrant/util/ssh.rb b/lib/vagrant/util/ssh.rb index a5bcaafe2..b1a670da7 100644 --- a/lib/vagrant/util/ssh.rb +++ b/lib/vagrant/util/ssh.rb @@ -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] diff --git a/templates/locales/en.yml b/templates/locales/en.yml index ebc9f683d..434d31733 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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