问题
Getting error connection refused error when trying to connect to the host to copy a local file to the host server. Don't have any issue connecting to the server remotely though.
host = "9.29.22.222"
username = "XXX"
password = "XXX"
local_path = "/Users/samuelhii/Desktop/file.txt"
remote_path = "C:\Program Files (x86)\file.txt"
s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect(host,22,username,password)
sftp = s.open_sftp()
sftp.put(local_path,remote_path)
回答1:
The connection was refused by the server. This can be caused by several reasons not related to Python programming:
- a firewall
- the SSH service is configure not to take requests from your IP
- bad host ip
- … (many more)
Check if you can use the normal SSH client to connect with this host/user/password combination.
来源:https://stackoverflow.com/questions/29093568/getting-socket-error-errno-61-connection-refused-python-paramiko