I am using Alteryx python paramiko library to establish a socks5 proxy connection with other system for file transfer. I am not an expert in python, I tried with below code, getting the Module not found error. It's not clear where this is breaking. Please share any insights you have on this.
from ayx import Alteryx
import paramiko
import socks
# Configuration - replace with your values
PROXY_HOST = '********'
PROXY_PORT = '****' # Default SOCKS5 port
SFTP_HOST = '******'
SFTP_PORT = '**'
USERNAME = '******'
PASSWORD = '*****' # Or use key-based auth
REMOTE_PATH = 'sftp://***/'
# Get the output file path
local_path = '****.xlsx'
# Set up SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, PROXY_HOST, PROXY_PORT)
paramiko.client.socket.socket = socks.socksocket
# Create SSH client
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
# Connect through proxy to SFTP
ssh.connect(SFTP_HOST, port=SFTP_PORT,
username=USERNAME, password=PASSWORD, timeout=180)
# Upload file
sftp = ssh.open_sftp()
sftp.put(local_path, REMOTE_PATH)
sftp.close()
print("File uploaded successfully!")
except Exception as e:
print(f"SFTP Error: {str(e)}")
finally:
ssh.close() if 'ssh' in locals() else None