module KnifeSSHAgent::Authenticator
Public Instance Methods
load_agent_default_ident()
click to toggle source
# File lib/knife/ssh-agent/authenticator.rb, line 26 def load_agent_default_ident agent = Net::SSH::Authentication::Agent.connect ident = agent.identities.select { |id| id.ssh_type == 'ssh-rsa' } raise AgentException, 'cannot retrieve a valid RSA key from the SSH agent' if ident.empty? ident.first ensure agent&.close end
load_ident_file(path)
click to toggle source
# File lib/knife/ssh-agent/authenticator.rb, line 19 def load_ident_file(path) file = [path + '.pub'].find(path) { |f| ::File.exist?(::File.expand_path(f)) } Net::SSH::KeyFactory.load_public_key(file) rescue Net::SSH::Exception raise AgentException, "unable to find requested SSH identity: #{path}" end
load_signing_key(key_file, raw_key = nil)
click to toggle source
Calls superclass method
# File lib/knife/ssh-agent/authenticator.rb, line 6 def load_signing_key(key_file, raw_key = nil) use_agent = Chef::Config[:knife][:use_ssh_agent] ident_file = Chef::Config[:knife][:ssh_agent_identity] return super(key_file, raw_key) unless use_agent @key = if ident_file load_ident_file(ident_file) else load_agent_default_ident end end