Method: Net::SSH::Authentication::KeyManager#each_identity
- Defined in:
- lib/net/ssh/authentication/key_manager.rb
#each_identity ⇒ Object
Iterates over all available identities (public keys) known to this manager. As it finds one, it will then yield it to the caller. The origin of the identities may be from files on disk or from an ssh-agent. Note that identities from an ssh-agent are always listed first in the array, with other identities coming after.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/net/ssh/authentication/key_manager.rb', line 93 def each_identity if agent agent.identities.each do |key| known_identities[key] = { :from => :agent } yield key end end key_files.each do |file| public_key_file = file + ".pub" if File.readable?(public_key_file) begin key = KeyFactory.load_public_key(public_key_file) known_identities[key] = { :from => :file, :file => file } yield key rescue Exception => e error { "could not load public key file `#{public_key_file}': #{e.class} (#{e.})" } end elsif File.readable?(file) begin private_key = KeyFactory.load_private_key(file, [:passphrase]) key = private_key.send(:public_key) known_identities[key] = { :from => :file, :file => file, :key => private_key } yield key rescue Exception => e error { "could not load private key file `#{file}': #{e.class} (#{e.})" } end end end key_data.each do |data| private_key = KeyFactory.load_data_private_key(data) key = private_key.send(:public_key) known_identities[key] = { :from => :key_data, :data => data, :key => private_key } yield key end self end |