File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/client.tar
Back
agent.py 0000644 00000003351 15030320052 0006204 0 ustar 00 # -*- test-case-name: twisted.conch.test.test_default -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Accesses the key agent for user authentication. Maintainer: Paul Swartz """ import os from twisted.conch.ssh import agent, channel, keys from twisted.internet import protocol, reactor from twisted.logger import Logger class SSHAgentClient(agent.SSHAgentClient): _log = Logger() def __init__(self): agent.SSHAgentClient.__init__(self) self.blobs = [] def getPublicKeys(self): return self.requestIdentities().addCallback(self._cbPublicKeys) def _cbPublicKeys(self, blobcomm): self._log.debug("got {num_keys} public keys", num_keys=len(blobcomm)) self.blobs = [x[0] for x in blobcomm] def getPublicKey(self): """ Return a L{Key} from the first blob in C{self.blobs}, if any, or return L{None}. """ if self.blobs: return keys.Key.fromString(self.blobs.pop(0)) return None class SSHAgentForwardingChannel(channel.SSHChannel): def channelOpen(self, specificData): cc = protocol.ClientCreator(reactor, SSHAgentForwardingLocal) d = cc.connectUNIX(os.environ["SSH_AUTH_SOCK"]) d.addCallback(self._cbGotLocal) d.addErrback(lambda x: self.loseConnection()) self.buf = "" def _cbGotLocal(self, local): self.local = local self.dataReceived = self.local.transport.write self.local.dataReceived = self.write def dataReceived(self, data): self.buf += data def closed(self): if self.local: self.local.loseConnection() self.local = None class SSHAgentForwardingLocal(protocol.Protocol): pass __pycache__/knownhosts.cpython-310.pyc 0000644 00000047302 15030320052 0013666 0 ustar 00 o �b�M � @ sP d Z ddlZddlZddlmZmZmZ ddlm Z ddl mZ ddlm Z ddlmZmZmZ ddlmZ dd lmZmZmZ dd lmZ ddlmZ ddlmZ dd lmZ ddl m!Z! e� Z"dd� Z#dd� Z$G dd� d�Z%e e�G dd� de%��Z&e e�G dd� d��Z'dd� Z(e e�G dd� de%e!��Z)G dd� d�Z*G dd � d �Z+dS )!zE An implementation of the OpenSSH known_hosts database. @since: 8.2 � N)�Error� a2b_base64� b2a_base64)�closing)�sha1)�implementer)�HostKeyChanged�InvalidEntry�UserRejectedKey)�IKnownHostEntry)�BadKeyError�FingerprintFormats�Key)�defer)�Logger)�nativeString)�secureRandom)�FancyEqMixinc C s t | ��� S )z� Encode a binary string as base64 with no trailing newline. @param s: The string to encode. @type s: L{bytes} @return: The base64-encoded string. @rtype: L{bytes} )r �strip)�s� r �A/usr/lib/python3/dist-packages/twisted/conch/client/knownhosts.py� _b64encode s r c C sz | � dd�}t|�dkrt� �|\}}}|� dd�}t|�dkr*|\}}|�d�}n|d }d}t�t|��}||||fS )a� Extract common elements of base64 keys from an entry in a hosts file. @param string: A known hosts file entry (a single line). @type string: L{bytes} @return: a 4-tuple of hostname data (L{bytes}), ssh key type (L{bytes}), key (L{Key}), and comment (L{bytes} or L{None}). The hostname data is simply the beginning of the line up to the first occurrence of whitespace. @rtype: L{tuple} N� � � � r )�split�lenr �rstripr � fromStringr ) �string�elements� hostnames�keyType� keyAndComment�splitkey� keyString�comment�keyr r r �_extractCommon- s r* c @ s e Zd ZdZdd� Zdd� ZdS )� _BaseEntrya� Abstract base of both hashed and non-hashed entry objects, since they represent keys and key types the same way. @ivar keyType: The type of the key; either ssh-dss or ssh-rsa. @type keyType: L{bytes} @ivar publicKey: The server public key indicated by this line. @type publicKey: L{twisted.conch.ssh.keys.Key} @ivar comment: Trailing garbage after the key line. @type comment: L{bytes} c C s || _ || _|| _d S �N)r$ � publicKeyr( )�selfr$ r- r( r r r �__init__X s z_BaseEntry.__init__c C s | j |kS )a Check to see if this entry matches a given key object. @param keyObject: A public key object to check. @type keyObject: L{Key} @return: C{True} if this entry's key matches C{keyObject}, C{False} otherwise. @rtype: L{bool} )r- )r. � keyObjectr r r � matchesKey] s z_BaseEntry.matchesKeyN)�__name__� __module__�__qualname__�__doc__r/ r1 r r r r r+ I s r+ c s<