获取“socket.error:[Errno 61]连接被拒绝”python paramiko
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29093568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting "socket.error: [Errno 61] Connection refused" python paramiko
提问by Sammy
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)
回答by Klaus D.
The connection was refused by the server. This can be caused by several reasons not related to Python programming:
连接被服务器拒绝。这可能是由与 Python 编程无关的几个原因引起的:
- a firewall
- the SSH service is configure not to take requests from your IP
- bad host ip
- … (many more)
- 防火墙
- SSH 服务配置为不接受来自您 IP 的请求
- 坏主机ip
- … (还有很多)
Check if you can use the normal SSH client to connect with this host/user/password combination.
检查是否可以使用普通的 SSH 客户端连接到这个主机/用户/密码组合。