Cache public keys for the duration of the agent

This saves a lot of time when connecting to multiple hosts
simultaneously (e.g., during a deploy) as every time we are asked to sign a
challenge, all public keys are iterated to find the correct one. This
can become especially slow when using the Bridge transport and/or many
identities are defined.
nistp521
Tomás Rojas 7 years ago committed by Roman Zeyde
parent 0d5c3a9ca7
commit 26d7dd3124
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

@ -147,8 +147,9 @@ class JustInTimeConnection(object):
"""Create a JIT connection object."""
self.conn_factory = conn_factory
self.identities = identities
self.public_keys = util.memoize(self._public_keys) # a simple cache
def public_keys(self):
def _public_keys(self):
"""Return a list of SSH public keys (in textual format)."""
conn = self.conn_factory()
return [conn.get_public_key(i) for i in self.identities]

Loading…
Cancel
Save