作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试连接到主机并使用模块 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/
我是一名优秀的程序员,十分优秀!