I'm trying to automate uploading and downloading files from sftp server. I've come up with the idea of creating an SSIS package with Python script doing the heavylifting and then running the SSIS package in SQL server job. I need to establish the connection to sftp server going through proxy server. I've come across a paramiko - Python implementation of SSH. I'm racking my brain how to use it to connect to my sftp server.
Here's my code:
import paramiko
hostname = "my_sftp_host"
port=22
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
proxy = paramiko.proxy.ProxyCommand(
'/usr/bin/nc --proxy my_server_proxy %s %d' \
% (hostname, port) )
ssh = paramiko.Transport(sock=proxy)
ssh.connect(username='***', password='***')
sftp = paramiko.SFTPClient.from_transport(ssh)
And the errors I'm getting:
Traceback (most recent call last):
File "C:\Python\PythON-Wtajemniczenie\LibrisSFTP.py", line 7, in <module>
proxy = paramiko.proxy.ProxyCommand(
File "C:\Users\arkadiusz.drezek\AppData\Local\Programs\Python\Python310\lib\site-packages\paramiko\proxy.py", line 62, in __init__
self.process = subprocess.Popen(
File "C:\Users\arkadiusz.drezek\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\arkadiusz.drezek\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Nie można odnaleźć określonego pliku
The error-message translated:
FileNotFoundError: [WinError 2] The system cannot find the file specified