I am trying to connect a remote server using Paramiko and send some files to other remote server. I tried the code below, but it didn't work. I checked all connections, username and password parameters, they don't have any problem. Also the file which I want to transfer exist in first remote server in proper path.
The reason why I don't download files to my local computer and upload to second server is, connection speed between two remote servers is a lot faster.
Things that I tried:
I set paramiko log level to debug, but couldn't find any useful information.
I tried same
scp
command from first server to second server from command line, worked fine.I tried to log by
data = stdout.readlines()
afterstdin.flush()
line but that didn't log anything.
import paramiko
s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect("10.10.10.10", 22, username='oracle', password='oracle', timeout=4)
stdin, stdout, stderr = s.exec_command(
"scp /home/oracle/myFile.txt oracle@10.10.10.20:/home/oracle/myFile.txt")
stdin.write('password\n')
stdin.flush()
s.close()