gpt4 book ai didi

python - 如何在 Fabric 2 中使用 Connection?

转载 作者:太空狗 更新时间:2023-10-30 01:04:34 25 4
gpt4 key购买 nike

我正在尝试连接到主机并使用模块 Fabric 2 运行命令并出现此错误:

Traceback (most recent call last):
File "Utilities/fabfile.py", line 4, in <module>
res.run('uname -s')
File "<decorator-gen-3>", line 2, in run
File "/usr/local/lib/python2.7/dist-packages/fabric/connection.py", line 29, in opens
self.open()
File "/usr/local/lib/python2.7/dist-packages/fabric/connection.py", line 501, in open
self.client.connect(**kwargs)
File "/home/trishnevskaya/.local/lib/python2.7/site-packages/paramiko/client.py", line 424, in connect
passphrase,
File "/home/username/.local/lib/python2.7/site-packages/paramiko/client.py", line 715, in _auth
raise SSHException('No authentication methods available')
paramiko.ssh_exception.SSHException: No authentication methods available

来自文档的简单代码(http://docs.fabfile.org/en/latest/getting-started.html):

from fabric import Connection

res = Connection('<host-ip>')
res.run('uname -s')

根据文档,我不需要特殊配置,但它不起作用...

织物 2.1.3
python 2.7.14

最佳答案

以下对我有用。

connect_kwargs = {"key_filename":['PATH/KEY.pem']}
with Connection(host="EC2", user="ubuntu", connect_kwargs=connect_kwargs) as c:
c.run("mkdir abds")

关于python - 如何在 Fabric 2 中使用 Connection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50710124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com