Use test SSH commands for additional verification SSH is "up"

This commit is contained in:
Mitchell Hashimoto 2011-11-25 23:48:00 -07:00
parent 15efdf5a1a
commit 8bb6d375f1
1 changed files with 8 additions and 4 deletions

View File

@ -115,15 +115,19 @@ module Vagrant
require 'timeout' require 'timeout'
Timeout.timeout(env.config.ssh.timeout) do Timeout.timeout(env.config.ssh.timeout) do
execute(:timeout => env.config.ssh.timeout, execute(:timeout => env.config.ssh.timeout, :port => ssh_port) do |ssh|
:port => ssh_port) { |ssh| } # We run a basic command to test that the shell is up and
# ready to receive commands. Only then is our SSH connection
# truly "up"
return ssh.exec!("echo hello") == "hello\n"
end
end end
true false
rescue Net::SSH::AuthenticationFailed rescue Net::SSH::AuthenticationFailed
raise Errors::SSHAuthenticationFailed raise Errors::SSHAuthenticationFailed
rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect, rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect,
Errors::SSHConnectionRefused, Net::SSH::AuthenticationFailed Errors::SSHConnectionRefused
return false return false
end end