任何人都可以帮助我,尝试将文件上传到外部sftp。
我收到的错误消息是paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
。我尝试用谷歌搜索一些解决方案,但不幸的是,它们都没有用。
target_host = 'your-experience-survey.com'
target_port = 22
target_username ='xx'
target_password = 'xxxx'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
proxy =('proxyexample.com',80)
sock.connect(proxy)
target =(target_host, target_port)
cmd_connect = ('CONNECT ' + target_host + ':' + str(target_port) +
'HTTP/1.1\r\nProxy-Authorization: Basic ' +
base64.b64encode('username:password'.encode()).decode() + '\r\n\r\n')
sock.sendall(cmd_connect.encode())
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=target_host,
port=target_port,
username=target_username,
password=target_password,
sock=sock)
sftp = ssh.open_sftp()
sftp.put(dataOutputPath + 'test.txt', iquoba_sftp + 'test.txt')
ssh.close()