Getting “socket.error: [Errno 61] Connection refused” python paramiko

白昼怎懂夜的黑 提交于 2019-12-02 04:09:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!