ó õùPc@s®dZddlZddlZddlZddlZddlmZddlmZddl m Z e ddƒ\Z Z ZZdd d „ƒYZd e fd „ƒYZdS( s' SSH Agent interface for Unix clients. iÿÿÿÿN(t SSHException(tMessage(tPKeyi itAgentcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sò Client interface for using private keys from an SSH agent running on the local machine. If an SSH agent is running, this class can be used to connect to it and retreive L{PKey} objects which can be used when attempting to authenticate to remote SSH servers. Because the SSH agent protocol uses environment variables and unix-domain sockets, this probably doesn't work on Windows. It does work on most posix platforms though (Linux and MacOS X, for example). cCsMd|_d|_dtjkrwtjdkrwtjtjtj ƒ}y|j tjdƒWndSX||_nDtjdkr·ddl }|j ƒr°|j ƒ|_q»dSndS|jttƒƒ\}}|tkrñtdƒ‚ng}x@t|jƒƒD],}|jt||jƒƒƒ|jƒq Wt|ƒ|_dS(s8 Open a session with the local machine's SSH agent, if one is running. If no agent is running, initialization will succeed, but L{get_keys} will return an empty tuple. @raise SSHException: if an SSH agent is found, but speaks an incompatible protocol t SSH_AUTH_SOCKtwin32Niÿÿÿÿs!could not get keys from ssh-agent((tNonetconntkeystostenvirontsystplatformtsockettAF_UNIXt SOCK_STREAMtconnectt win_pageanttcan_talk_to_agenttPageantConnectiont _send_messagetchrtSSH2_AGENTC_REQUEST_IDENTITIEStSSH2_AGENT_IDENTITIES_ANSWERRtrangetget_inttappendtAgentKeyt get_stringttuple(tselfRRtptypetresultRti((s)..\python\site-packages\paramiko\agent.pyt__init__1s.      cCs5|jdk r|jjƒnd|_d|_dS(s1 Close the SSH agent connection. N((RRtcloseR(R((s)..\python\site-packages\paramiko\agent.pyR#Ws cCs|jS(s' Return the list of keys available through the SSH agent, if any. If no SSH agent was running (or it couldn't be contacted), an empty list will be returned. @return: a list of keys available on the SSH agent @rtype: tuple of L{AgentKey} (R(R((s)..\python\site-packages\paramiko\agent.pytget_keys`s cCs|t|ƒ}|jjtjdt|ƒƒ|ƒ|jdƒ}t|jtjd|ƒdƒƒ}t |j ƒƒ|fS(Ns>Iii( tstrRtsendtstructtpacktlent _read_allRtunpacktordtget_byte(Rtmsgtl((s)..\python\site-packages\paramiko\agent.pyRks  &%cCs—|jj|ƒ}x~t|ƒ|kr’t|ƒdkrHtdƒ‚n|jj|t|ƒƒ}t|ƒdkr…tdƒ‚n||7}qW|S(Nislost ssh-agent(RtrecvR)R(RtwantedR textra((s)..\python\site-packages\paramiko\agent.pyR*rs(t__name__t __module__t__doc__R"R#R$RR*(((s)..\python\site-packages\paramiko\agent.pyR%s   & RcBs2eZdZd„Zd„Zd„Zd„ZRS(s´ Private key held in a local SSH agent. This type of key can be used for authenticating to a remote server (signing). Most other key operations work as expected. cCs+||_||_t|ƒjƒ|_dS(N(tagenttblobRRtname(RR6R7((s)..\python\site-packages\paramiko\agent.pyR"…s  cCs|jS(N(R7(R((s)..\python\site-packages\paramiko\agent.pyt__str__ŠscCs|jS(N(R8(R((s)..\python\site-packages\paramiko\agent.pytget_namescCsƒtƒ}|jttƒƒ|j|jƒ|j|ƒ|jdƒ|jj|ƒ\}}|t kryt dƒ‚n|j ƒS(Niskey cannot be used for signing( Rtadd_byteRtSSH2_AGENTC_SIGN_REQUESTt add_stringR7tadd_intR6RtSSH2_AGENT_SIGN_RESPONSERR(RtrngtdataR.RR ((s)..\python\site-packages\paramiko\agent.pyt sign_ssh_datas    (R3R4R5R"R9R:RB(((s)..\python\site-packages\paramiko\agent.pyR~s    ((R5R R R'R tparamiko.ssh_exceptionRtparamiko.messageRt paramiko.pkeyRRRRR<R?RR(((s)..\python\site-packages\paramiko\agent.pyts    Y