Reputation: 41
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)
Upvotes: 4
Views: 60255
Reputation: 14369
The connection was refused by the server. This can be caused by several reasons not related to Python programming:
Check if you can use the normal SSH client to connect with this host/user/password combination.
Upvotes: 6