Methods
Classes and Modules
Module Net::SSH::UserAuth::ConstantsModule Net::SSH::UserAuth::Methods
Module Net::SSH::UserAuth::Pageant
Class Net::SSH::UserAuth::Agent
Class Net::SSH::UserAuth::AgentError
Class Net::SSH::UserAuth::Driver
Class Net::SSH::UserAuth::UserKeyManager
Class Net::SSH::UserAuth::UserKeyManagerError
Public Instance methods
[ show source ]
# File lib/net/ssh/userauth/services.rb, line 21 21: def register_services( container ) 22: container.namespace_define :userauth do |b| 23: 24: b.require 'net/ssh/userauth/methods/services', "#{self}::Methods" 25: 26: b.agent_socket_factory do 27: if File::ALT_SEPARATOR 28: require 'net/ssh/userauth/pageant' 29: Pageant::Socket 30: else 31: require 'socket' 32: defined?( UNIXSocket ) ? UNIXSocket : nil 33: end 34: end 35: 36: b.default_agent_socket_name { ENV['SSH_AUTH_SOCK'] } 37: 38: b.default_agent_version { 2 } 39: 40: b.agent( :model => :prototype ) do |c,p| 41: socket_factory = c[:agent_socket_factory] 42: socket_name = c[:default_agent_socket_name] 43: 44: if (File::ALT_SEPARATOR || socket_name) && socket_factory 45: require 'net/ssh/userauth/agent' 46: require 'net/ssh/transport/services' 47: 48: agent = Agent.new 49: agent.socket_factory = socket_factory 50: agent.socket_name = socket_name 51: agent.version = c[:default_agent_version] 52: agent.buffers = c[:transport][:buffers] 53: agent.keys = c[:transport][:keys] 54: 55: begin 56: agent.connect! 57: rescue Net::SSH::Exception 58: # if there was an error connecting to the agent, swallow the 59: # error and move on, without the agent 60: agent = nil 61: end 62: end 63: 64: agent 65: end 66: 67: b.agent_factory do |c,p| 68: factory = Object.new 69: klass = class << factory; self; end 70: klass.send( :define_method, :open ) { c[:agent] } 71: factory 72: end 73: 74: b.default_user_key_locations do 75: [ "#{ENV['HOME']}/.ssh/id_dsa", 76: "#{ENV['HOME']}/.ssh2/id_dsa", 77: "#{ENV['HOME']}/.ssh/id_rsa", 78: "#{ENV['HOME']}/.ssh2/id_rsa" ] 79: end 80: 81: b.default_host_key_locations do 82: [ "/etc/ssh/ssh_host_dsa_key", 83: "/etc/ssh/ssh_host_rsa_key" ] 84: end 85: 86: b.key_existence_tester { File } 87: 88: b.user_keys do |c,p| 89: require 'net/ssh/userauth/userkeys' 90: 91: userkeys = UserKeyManager.new 92: userkeys.agent_factory = c[:agent_factory] 93: userkeys.keys = c[:transport][:keys] 94: userkeys.buffers = c[:transport][:buffers] 95: userkeys.log = c[:log_for, p] 96: userkeys.key_existence_tester = b.key_existence_tester 97: 98: b.default_user_key_locations.each { |f| userkeys.add f } 99: b.default_host_key_locations.each { |f| userkeys.add_host_key f } 100: 101: userkeys 102: end 103: 104: b.authentication_method_order do 105: [ "publickey", 106: "hostbased", 107: "password", 108: "keyboard-interactive" ] 109: end 110: 111: b.driver do |c,p| 112: require 'net/ssh/userauth/driver' 113: 114: driver = Driver.new( c[:log_for, p], 115: c[:transport][:buffers], 116: c[:methods], 117: c[:authentication_method_order] ) 118: 119: driver.key_manager = c[:user_keys] 120: driver.session = c[:transport][:session] 121: 122: if c.knows_key?(:userauth_keys) && c[:userauth_keys] 123: driver.set_key_files c[:userauth_keys] 124: end 125: if c.knows_key?(:userauth_host_keys) && c[:userauth_host_keys] 126: driver.set_host_key_files c[:userauth_host_keys] 127: end 128: if c.knows_key?(:userauth_method_order) && c[:userauth_method_order] 129: driver.set_auth_method_order *c[:userauth_method_order] 130: end 131: 132: driver 133: end 134: 135: end 136: end