Check key permissions on SSH execute (must be 0600)
This commit is contained in:
parent
af07bd0d3b
commit
e6f628b98b
|
@ -42,6 +42,9 @@ module Vagrant
|
|||
# Opens an SSH connection to this environment's virtual machine and yields
|
||||
# a Net::SSH object which can be used to execute remote commands.
|
||||
def execute(opts={})
|
||||
# Check the key permissions to avoid SSH hangs
|
||||
check_key_permissions(env.config.ssh.private_key_path)
|
||||
|
||||
Net::SSH.start(env.config.ssh.host,
|
||||
env.config[:ssh][:username],
|
||||
opts.merge( :port => port,
|
||||
|
|
|
@ -85,6 +85,14 @@ class SshTest < Test::Unit::TestCase
|
|||
context "executing ssh commands" do
|
||||
setup do
|
||||
mock_ssh
|
||||
@ssh.stubs(:check_key_permissions)
|
||||
end
|
||||
|
||||
should "check key permissions then attempt to start connection" do
|
||||
seq = sequence("seq")
|
||||
@ssh.expects(:check_key_permissions).with(@env.config.ssh.private_key_path).once.in_sequence(seq)
|
||||
Net::SSH.expects(:start).once.in_sequence(seq)
|
||||
@ssh.execute
|
||||
end
|
||||
|
||||
should "call net::ssh.start with the proper names" do
|
||||
|
@ -123,6 +131,7 @@ class SshTest < Test::Unit::TestCase
|
|||
context "checking if host is up" do
|
||||
setup do
|
||||
mock_ssh
|
||||
@ssh.stubs(:check_key_permissions)
|
||||
end
|
||||
|
||||
should "return true if SSH connection works" do
|
||||
|
|
Loading…
Reference in New Issue