获取“socket.error: [Errno 61] 连接被拒绝";蟒蛇 [英] Getting "socket.error: [Errno 61] Connection refused" python paramiko

查看:154
本文介绍了获取“socket.error: [Errno 61] 连接被拒绝";蟒蛇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试连接到主机以将本地文件复制到主机服务器时出现错误连接拒绝错误.但是远程连接到服务器没有任何问题.

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) 

推荐答案

连接被服务器拒绝.这可能是由与 Python 编程无关的几个原因造成的:

The connection was refused by the server. This can be caused by several reasons not related to Python programming:

  • 防火墙
  • SSH 服务配置为不接受来自您 IP 的请求
  • 错误的主机 ip
  • …(更多)

检查是否可以使用普通的 SSH 客户端连接到这个主机/用户/密码组合.

Check if you can use the normal SSH client to connect with this host/user/password combination.

这篇关于获取“socket.error: [Errno 61] 连接被拒绝";蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆