From 8bb6d375f15d5bd4449573e92a1cb0577b3e678f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 25 Nov 2011 23:48:00 -0700 Subject: [PATCH] Use test SSH commands for additional verification SSH is "up" --- lib/vagrant/ssh.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 581291016..6bbb8cfc6 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -115,15 +115,19 @@ module Vagrant require 'timeout' Timeout.timeout(env.config.ssh.timeout) do - execute(:timeout => env.config.ssh.timeout, - :port => ssh_port) { |ssh| } + execute(:timeout => env.config.ssh.timeout, :port => ssh_port) do |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 - true + false rescue Net::SSH::AuthenticationFailed raise Errors::SSHAuthenticationFailed rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect, - Errors::SSHConnectionRefused, Net::SSH::AuthenticationFailed + Errors::SSHConnectionRefused return false end