Merge pull request #2557 from fgrehm/fix-vagrant-ssh
core: `vagrant ssh` and `vagrant ssh -c` should handle multiple SSH keys
This commit is contained in:
commit
fbf9b09913
|
@ -29,8 +29,10 @@ module Vagrant
|
||||||
raise Errors::SSHNotReady if info.nil?
|
raise Errors::SSHNotReady if info.nil?
|
||||||
|
|
||||||
if info[:private_key_path]
|
if info[:private_key_path]
|
||||||
# Check the SSH key permissions
|
# Check SSH key permissions
|
||||||
SSH.check_key_permissions(Pathname.new(info[:private_key_path]))
|
info[:private_key_path].each do |path|
|
||||||
|
SSH.check_key_permissions(Pathname.new(path))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Exec!
|
# Exec!
|
||||||
|
|
|
@ -9,6 +9,9 @@ module Vagrant
|
||||||
# mirror the output to the UI. The resulting exit status of the command
|
# mirror the output to the UI. The resulting exit status of the command
|
||||||
# will exist in the `:ssh_run_exit_status` key in the environment.
|
# will exist in the `:ssh_run_exit_status` key in the environment.
|
||||||
class SSHRun
|
class SSHRun
|
||||||
|
# For quick access to the `SSH` class.
|
||||||
|
include Vagrant::Util
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@app = app
|
@app = app
|
||||||
@logger = Log4r::Logger.new("vagrant::action::builtin::ssh_run")
|
@logger = Log4r::Logger.new("vagrant::action::builtin::ssh_run")
|
||||||
|
@ -23,8 +26,10 @@ module Vagrant
|
||||||
raise Errors::SSHNotReady if info.nil?
|
raise Errors::SSHNotReady if info.nil?
|
||||||
|
|
||||||
if info[:private_key_path]
|
if info[:private_key_path]
|
||||||
# Check the SSH key permissions
|
# Check SSH key permissions
|
||||||
Util::SSH.check_key_permissions(Pathname.new(info[:private_key_path]))
|
info[:private_key_path].each do |path|
|
||||||
|
SSH.check_key_permissions(Pathname.new(path))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Execute!
|
# Execute!
|
||||||
|
|
|
@ -30,10 +30,11 @@ describe Vagrant::Action::Builtin::SSHExec do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should check key permissions then exec" do
|
it "should check key permissions then exec" do
|
||||||
machine_ssh_info[:private_key_path] = "/foo"
|
key_path = "/foo"
|
||||||
|
machine_ssh_info[:private_key_path] = [key_path]
|
||||||
|
|
||||||
ssh_klass.should_receive(:check_key_permissions).
|
ssh_klass.should_receive(:check_key_permissions).
|
||||||
with(Pathname.new(machine_ssh_info[:private_key_path])).
|
with(Pathname.new(key_path)).
|
||||||
once.
|
once.
|
||||||
ordered
|
ordered
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue