Created
March 20, 2013 13:44
-
-
Save krames/5204730 to your computer and use it in GitHub Desktop.
This patch makes ssh timeout configurable. Example: require 'fog'
require 'fog_ssh_patch.rb' ssh = Fog::SSH.new HOST, USERNAME, :timeout => 60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Fog::VERSION == "1.10.0" | |
Fog::Logger.warning "PATCHING Fog::SSH::Real so that the timeout is user configurable" | |
require 'rubygems' | |
require 'fog' | |
module Fog | |
module SSH | |
class Real | |
def initialize(address, username, options) | |
require 'net/ssh' | |
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options) | |
unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent | |
raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH') | |
end | |
options[:timeout] ||= 30 | |
if options[:key_data] || options[:keys] | |
options[:keys_only] = true | |
#Explicitly set these so net-ssh doesn't add the default keys | |
#as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146 | |
options[:keys] = [] unless options[:keys] | |
options[:key_data] = [] unless options[:key_data] | |
end | |
@address = address | |
@username = username | |
@options = { :paranoid => false }.merge(options) | |
end | |
end | |
end | |
end | |
else | |
Fog::Logger.warning "PATCHING Fog::SSH::Real - does not apply for #{Fog::VERSION}. Please remove it." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment