SSH gives error message if `ssh` binary is not found. [closes GH-161]
This commit is contained in:
parent
0fcc1150c5
commit
c5b81b5998
|
@ -1,5 +1,6 @@
|
||||||
## 0.6.4 (unreleased)
|
## 0.6.4 (unreleased)
|
||||||
|
|
||||||
|
- SSH gives error message if `ssh` binary is not found. [GH-161]
|
||||||
- SSH gives proper error message if VM is not running. [GH-167]
|
- SSH gives proper error message if VM is not running. [GH-167]
|
||||||
- Fix some issues with undefined constants in command errors.
|
- Fix some issues with undefined constants in command errors.
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,11 @@ module Vagrant
|
||||||
error_key(:ssh_key_bad_permissions)
|
error_key(:ssh_key_bad_permissions)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class SSHUnavailable < VagrantError
|
||||||
|
status_code(45)
|
||||||
|
error_key(:ssh_unavailable)
|
||||||
|
end
|
||||||
|
|
||||||
class SSHUnavailableWindows < VagrantError
|
class SSHUnavailableWindows < VagrantError
|
||||||
status_code(10)
|
status_code(10)
|
||||||
error_key(:ssh_unavailable_windows)
|
error_key(:ssh_unavailable_windows)
|
||||||
|
|
|
@ -26,6 +26,8 @@ module Vagrant
|
||||||
:ssh_port => port(opts))
|
:ssh_port => port(opts))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
raise Errors::SSHUnavailable.new if !Kernel.system("which ssh > /dev/null 2>&1")
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
options[:port] = port(opts)
|
options[:port] = port(opts)
|
||||||
[:host, :username, :private_key_path].each do |param|
|
[:host, :username, :private_key_path].each do |param|
|
||||||
|
|
|
@ -43,6 +43,7 @@ en:
|
||||||
permissions on the following file to 0600 and then try running this command again:
|
permissions on the following file to 0600 and then try running this command again:
|
||||||
|
|
||||||
%{key_path}
|
%{key_path}
|
||||||
|
ssh_unavailable: "`ssh` binary could not be found. Is an SSH client installed?"
|
||||||
ssh_unavailable_windows: |-
|
ssh_unavailable_windows: |-
|
||||||
`vagrant ssh` isn't available on the Windows platform. The
|
`vagrant ssh` isn't available on the Windows platform. The
|
||||||
vagrant.ppk file for use with Putty is available at:
|
vagrant.ppk file for use with Putty is available at:
|
||||||
|
|
|
@ -22,10 +22,23 @@ class SshTest < Test::Unit::TestCase
|
||||||
mock_ssh
|
mock_ssh
|
||||||
@ssh.stubs(:check_key_permissions)
|
@ssh.stubs(:check_key_permissions)
|
||||||
Kernel.stubs(:exec)
|
Kernel.stubs(:exec)
|
||||||
|
Kernel.stubs(:system).returns(true)
|
||||||
|
|
||||||
Vagrant::Util::Platform.stubs(:leopard?).returns(false)
|
Vagrant::Util::Platform.stubs(:leopard?).returns(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "raise an exception if SSH is not found" do
|
||||||
|
Kernel.stubs(:system).returns(false)
|
||||||
|
Kernel.expects(:system).returns(false).with() do |command|
|
||||||
|
assert command =~ /^which ssh/
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raises(Vagrant::Errors::SSHUnavailable) {
|
||||||
|
@ssh.connect
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
should "check key permissions prior to exec" do
|
should "check key permissions prior to exec" do
|
||||||
exec_seq = sequence("exec_seq")
|
exec_seq = sequence("exec_seq")
|
||||||
@ssh.expects(:check_key_permissions).with(@env.config.ssh.private_key_path).once.in_sequence(exec_seq)
|
@ssh.expects(:check_key_permissions).with(@env.config.ssh.private_key_path).once.in_sequence(exec_seq)
|
||||||
|
|
Loading…
Reference in New Issue