Код: Выделить всё
if(remote_path not exist):
create_path(remote_path)
upload_file(local_file, remote_path)
Код: Выделить всё
# I didn't test this code
import paramiko, sys
ssh = paramiko.SSHClient()
ssh.connect(myhost, 22, myusername, mypassword)
ssh.exec_command('mkdir -p ' + remote_path)
ssh.close
transport = paramiko.Transport((myhost, 22))
transport.connect(username = myusername, password = mypassword)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put(local_path, remote_path)
sftp.close()
transport.close()
Подробнее здесь: https://stackoverflow.com/questions/148 ... esnt-exist