def discover_ssh_executable
@ssh_executable ||= begin
guessing_locations = ['ssh']
if RHC::Helpers.windows?
guessing_locations <<
discover_windows_executables do |base|
[
'ssh.exe',
"#{base}\\Git\\bin\\ssh.exe",
"#{base}\\ssh.exe",
'plink.exe',
"#{base}\\PuTTY\\plink.exe",
"#{base}\\plink.exe",
'putty.exe',
"#{base}\\PuTTY\\putty.exe",
"#{base}\\putty.exe"
]
end
end
guessing_locations.flatten.uniq.select do |cmd|
(check_ssh_executable!(cmd).present? rescue false) &&
(begin
cmd =~ /plink\.exe/i || cmd =~ /putty\.exe/i || (begin
ssh_version(cmd)
$?.success?
end)
rescue ; false ; end)
end.collect{|cmd| cmd =~ / / ? '"' + cmd + '"' : cmd}.first
end
end