#NEWLINE# def _auth( self , username , password , key_filenames , allow_agent , look_for_keys ) : #NEWLINE# #INDENT# saved_exception = None #NEWLINE# for key_filename in key_filenames : #NEWLINE# #INDENT# for cls in ( paramiko . RSAKey , paramiko . DSSKey ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# key = cls . from_private_key_file ( key_filename , password ) #NEWLINE# logger . debug ( 'Trying key %s from %s' , hexlify ( key . get_fingerprint ( ) ) , key_filename ) #NEWLINE# self . _transport . auth_publickey ( username , key ) #NEWLINE# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# saved_exception = e #NEWLINE# logger . debug ( e ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if allow_agent : #NEWLINE# #INDENT# for key in paramiko . Agent ( ) . get_keys ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# logger . debug ( 'Trying SSH agent key %s' , hexlify ( key . get_fingerprint ( ) ) ) #NEWLINE# self . _transport . auth_publickey ( username , key ) #NEWLINE# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# saved_exception = e #NEWLINE# logger . debug ( e ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# keyfiles = [ ] #NEWLINE# if look_for_keys : #NEWLINE# #INDENT# rsa_key = os . path . expanduser ( '~/.ssh/id_rsa' ) #NEWLINE# dsa_key = os . path . expanduser ( '~/.ssh/id_dsa' ) #NEWLINE# if os . path . isfile ( rsa_key ) : #NEWLINE# #INDENT# keyfiles . append ( ( paramiko . RSAKey , rsa_key ) ) #NEWLINE# #UNINDENT# if os . path . isfile ( dsa_key ) : #NEWLINE# #INDENT# keyfiles . append ( ( paramiko . DSSKey , dsa_key ) ) #NEWLINE# #UNINDENT# rsa_key = os . path . expanduser ( '~/ssh/id_rsa' ) #NEWLINE# dsa_key = os . path . expanduser ( '~/ssh/id_dsa' ) #NEWLINE# if os . path . isfile ( rsa_key ) : #NEWLINE# #INDENT# keyfiles . append ( ( paramiko . RSAKey , rsa_key ) ) #NEWLINE# #UNINDENT# if os . path . isfile ( dsa_key ) : #NEWLINE# #INDENT# keyfiles . append ( ( paramiko . DSSKey , dsa_key ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( cls , filename ) in keyfiles : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# key = cls . from_private_key_file ( filename , password ) #NEWLINE# logger . debug ( 'Trying discovered key %s in %s' , hexlify ( key . get_fingerprint ( ) ) , filename ) #NEWLINE# self . _transport . auth_publickey ( username , key ) #NEWLINE# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# saved_exception = e #NEWLINE# logger . debug ( e ) #NEWLINE# #UNINDENT# #UNINDENT# if ( password is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . _transport . auth_password ( username , password ) #NEWLINE# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# saved_exception = e #NEWLINE# logger . debug ( e ) #NEWLINE# #UNINDENT# #UNINDENT# if ( saved_exception is not None ) : #NEWLINE# #INDENT# raise AuthenticationError ( repr ( saved_exception ) ) #NEWLINE# #UNINDENT# raise AuthenticationError ( 'No authentication methods available' )