我想删除我已经使用 Paramiko 连接到的远程服务器上给定目录中的所有文件。不过,我不能明确给出文件名,因为这些会根据我之前放在那里的文件版本而有所不同。
这就是我想要做的...... #TODO 下面的行是我正在尝试的调用,remoteArtifactPath
类似于/opt/foo/*
ssh = paramiko.SSHClient()
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
ssh.connect(server, username=username, pkey=mykey)
sftp = ssh.open_sftp()
# TODO: Need to somehow delete all files in remoteArtifactPath remotely
sftp.remove(remoteArtifactPath+"*")
# Close to end
sftp.close()
ssh.close()
知道如何实现这一目标吗?