def on_connect(agent): keys = yield agent.requestIdentities() # if the key is found in ssh-agent, the raw public key (32 bytes), and the # key comment as returned from ssh-agent key_data = None key_comment = None for blob, comment in keys: raw = _unpack(blob) algo = raw[0].decode('utf8') if algo == 'ssh-ed25519': algo, _pubkey = raw if _pubkey == pubkey: key_data = _pubkey key_comment = comment.decode('utf8') break agent.transport.loseConnection() if key_data: key = signing.VerifyKey(key_data) returnValue(cls(key, key_comment, reactor)) else: raise Exception("Ed25519 key not held in ssh-agent")
def on_connect(agent): keys = yield agent.requestIdentities() # if the key is found in ssh-agent, the raw public key (32 bytes), and the # key comment as returned from ssh-agent key_data = None key_comment = None for blob, comment in keys: raw = _unpack(blob) algo = raw[0] if algo == u'ssh-ed25519': algo, _pubkey = raw if _pubkey == pubkey: key_data = _pubkey key_comment = comment.decode('utf8') break agent.transport.loseConnection() if key_data: key = signing.VerifyKey(key_data) returnValue(cls(key, key_comment, reactor)) else: raise Exception("Ed25519 key not held in ssh-agent")
def on_connect(agent): # we are now connected to the locally running ssh-agent # that agent might be the openssh-agent, or eg on Ubuntu 14.04 by # default the gnome-keyring / ssh-askpass-gnome application blob = _pack(['ssh-ed25519', self.public_key(binary=True)]) # now ask the agent signature_blob = yield agent.signData(blob, challenge) algo, signature = _unpack(signature_blob) agent.transport.loseConnection() returnValue(signature)