def setUp(self): auth_cb = get_key_auth_cb(key_filepath) self.__client = SftpBackupClient(user, host, auth_cb, remote_backup_path) try: self.__client.easy.sftp.mkdir('/tmp/backup_deposit') except SftpAlreadyExistsError: pass
def connect_sftp_test(sftp_cb): print("Connecting SFTP with key: %s" % (key_filepath)) auth_cb = get_key_auth_cb(key_filepath) connect_sftp_with_cb(sftp_cb, user, host, auth_cb, verbosity=verbosity)
ch = logging.StreamHandler() ch.setFormatter(_FORMATTER) logger.addHandler(ch) _configure_logging() from pysecure.adapters.sftpa import SftpFile from pysecure.easy import connect_sftp_with_cb, get_key_auth_cb user = '******' host = 'localhost' key_filepath = '/Users/dustin/.ssh/id_dsa' auth_cb = get_key_auth_cb(key_filepath) # Or, for SFTP-enabled SSH functionality. def sftp_cb(ssh, sftp): print("Name Size Perms Owner\tGroup\n") for attributes in sftp.listdir('.'): print("%-40s %10d %.8o %s(%d)\t%s(%d)" % (attributes.name[0:40], attributes.size, attributes.permissions, attributes.owner, attributes.uid, attributes.group, attributes.gid)) connect_sftp_with_cb(sftp_cb, user, host, auth_cb)
def setUp(self): auth_cb = get_key_auth_cb(key_filepath) self.__easy = EasySsh(user, host, auth_cb) self.__easy.open_ssh() self.__easy.open_sftp()