#NEWLINE# def _connect( self ) : #NEWLINE# #INDENT# self . _ssh = paramiko . SSHClient ( ) #NEWLINE# if ( self . _known_host_file is not None ) : #NEWLINE# #INDENT# self . _ssh . load_host_keys ( self . _known_host_file ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _ssh . load_host_keys ( os . path . expanduser ( os . path . join ( '~' , '.ssh' , 'known_hosts' ) ) ) #NEWLINE# #UNINDENT# self . _ssh . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . _ssh . connect ( self . _host , ** self . _params ) #NEWLINE# #UNINDENT# except paramiko . AuthenticationException as e : #NEWLINE# #INDENT# if ( self . _interactive and ( 'password' not in e . _params ) ) : #NEWLINE# #INDENT# if ( 'username' not in self . _params ) : #NEWLINE# #INDENT# self . _params [ 'username' ] = getpass . getuser ( ) #NEWLINE# #UNINDENT# self . _params [ 'password' ] = getpass . getpass ( ) #NEWLINE# self . _connect ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise paramiko . AuthenticationException ( e ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# print ( e ) #NEWLINE# #UNINDENT# if ( not hasattr ( self , '_sftp' ) ) : #NEWLINE# #INDENT# self . _sftp = self . _ssh . open_sftp ( )