无法通过Paramiko连接到SFTP
我正在尝试与paramiko建立与SFTP的连接。我能够通过使用
ssh my.domain.com
结果文件在已知_ host的第一行中同时使用host and is ip生成已知的_host文件,例如
my.domain.com,xx.xx.xxx.xx ...
当我尝试通过paramiko连接时,
host, port = 'my.domain.com,xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
会出现错误
socket.gaierror: [Errno 11001] getaddrinfo failed
我在查找此之后 ,解决方案是不提及主机中的用户或添加端口,等等,但是我仍然无法联系。我尝试从python代码和nown_host文件中删除my.domain.com
,
host, port = 'xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
但这无效。我尝试从python代码和已知_host文件中删除xx.xx.xxx.xx.xx
,
host, port = 'xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
但这也不起作用。
如何连接到我的SFTP?
I am trying to establish a connection with an SFTP with paramiko. I was able to generate the known_hosts file in my local system by using
ssh my.domain.com
The resultant file has both the host and its IP in the first line of known_hosts, like
my.domain.com,xx.xx.xxx.xx ...
When I try to connect through paramiko,
host, port = 'my.domain.com,xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
I get the error
socket.gaierror: [Errno 11001] getaddrinfo failed
After looking this up, the solutions were to not mention user in host or add port, etc. But I'm still not able to connect. I tried removing my.domain.com
from both the Python code and known_hosts file,
host, port = 'xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
but that didn't work. I tried removing xx.xx.xxx.xx
from both the Python code and known_hosts file,
host, port = 'xx.xx.xxx.xx', 22
user, pwd = "xyz", "abc"
ssh = paramiko.SSHClient()
ssh.connect(host, port, username=user, password=pwd)
but that didn't work either.
How do I connect to my SFTP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@tdalaney在评论中解决的那样。我编辑了
nown_host
文件仅指定域名并添加ssh.load_system_host_keys()
connect> connect> connect 方法。As resolved by @tdalaney in the comments. I edited the
known_hosts
file to only specify the domain name and addedssh.load_system_host_keys()
before theconnect
method.