I'm trying to run the following code :
#!/data/go_dl/resources/miniconda3/envs/stg01.nifi_Env/bin/python
import sys
import paramiko
import socket
sftpHost = 'eng-test-host'
sftpPort = '22'
sftpUser = 'user_1'
sftpPass = '123456'
sftpPathSource = '/tmp/poc/'
localPath = '/data/poc/'
sftpIMGFiles = 'test.IMG'
transport=paramiko.Transport((sftpHost, sftpPort))
transport.connect(username=sftpUser, password=sftpPass)
sftp=paramiko.SFTPClient.from_transport(transport)
sftp.put(sftpPathSource + sftpIMGFiles + localPath + sftpIMGFiles)
sftp.close()
transport.close()
class FastTransport(paramiko.Transport):
def __init__(self, sock):
super(FastTransport, self).__init__(sock)
But I'm getting this error :
Traceback (most recent call last):
File "gettingTtsFile.py", line 18, in <module>
transport=paramiko.Transport((sftpHost, sftpPort))
File "/data/go_dl/resources/miniconda3/lib/python3.8/site-packages/paramiko/transport.py", line 409, in __init__
retry_on_signal(lambda: sock.connect((hostname, port)))
File "/data/go_dl/resources/miniconda3/lib/python3.8/site-packages/paramiko/util.py", line 283, in retry_on_signal
return function()
File "/data/go_dl/resources/miniconda3/lib/python3.8/site-packages/paramiko/transport.py", line 409, in <lambda>
retry_on_signal(lambda: sock.connect((hostname, port)))
TypeError: an integer is required (got type str)
Can someone help me? The Python version that I'm trying to run is 3.8.5 and Paramiko is 2.7.2.
Thanks
question from:
https://stackoverflow.com/questions/65932669/connecting-to-sftp-server-with-paramiko-fails-with-an-integer-is-required-got 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…