diff --git a/lib/vagrant/action/builtin/ssh_run.rb b/lib/vagrant/action/builtin/ssh_run.rb index 3636f1ab8..59b16f325 100644 --- a/lib/vagrant/action/builtin/ssh_run.rb +++ b/lib/vagrant/action/builtin/ssh_run.rb @@ -26,11 +26,15 @@ module Vagrant # not yet ready for SSH, so we raise this exception. raise Errors::SSHNotReady if info.nil? - if info[:private_key_path] - # Check SSH key permissions - info[:private_key_path].each do |path| - SSH.check_key_permissions(Pathname.new(path)) - end + info[:private_key_path] ||= [] + + # Check SSH key permissions + info[:private_key_path].each do |path| + SSH.check_key_permissions(Pathname.new(path)) + end + + if info[:private_key_path].empty? + raise Errors::SSHRunRequiresKeys end # Get the command and wrap it in a login shell diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index cfaad43c2..a4fd6090b 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -532,6 +532,10 @@ module Vagrant error_key(:ssh_port_not_detected) end + class SSHRunRequiresKeys < VagrantError + error_key(:ssh_run_requires_keys) + end + class SSHUnavailable < VagrantError error_key(:ssh_unavailable) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index b3939491f..154693760 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -650,6 +650,15 @@ en: Please make sure that you have a forwarded port that goes to the configured guest port value, or specify an explicit SSH port with `config.ssh.port`. + ssh_run_requires_keys: |- + Using `vagrant ssh -c` requires key-based SSH authentication, but your + Vagrant environmet is configured to use only password-based authentication. + Please configure your Vagrantfile with a private key to use this + feature. + + Note that Vagrant can automatically insert a keypair and use that + keypair for you. Just set `config.ssh.insert_key = true` in your + Vagrantfile. ssh_unavailable: "`ssh` binary could not be found. Is an SSH client installed?" ssh_unavailable_windows: |- `ssh` executable not found in any directories in the %PATH% variable. Is an