Python 织物未使用正确的键

Python 织物未使用正确的键,python,fabric,paramiko,Python,Fabric,Paramiko,在我的fabfile中,我已将env.use\ssh\u config设置为True。每当我运行fabfile,它都会从ssh配置中获得正确的hostname和user,但不是正确的密钥。它将随机遍历我的密钥(全部存储在~/.ssh/)并要求我输入所有密钥的密码短语,直到找到正确的密钥为止 Host example HostName example.com User elssar IdentityFile ~/.ssh/id_example PreferredAu

在我的
fabfile
中,我已将
env.use\ssh\u config
设置为
True
。每当我运行
fabfile
,它都会从ssh配置中获得正确的
hostname
user
,但不是正确的密钥。它将随机遍历我的密钥(全部存储在~/.ssh/)并要求我输入所有密钥的密码短语,直到找到正确的密钥为止

Host example
    HostName example.com
    User elssar
    IdentityFile ~/.ssh/id_example
    PreferredAuthentications publickey
这是唯一给我这个问题的布料。在文件中以
local
命令的形式运行
scp
,使用正确的键

Host example
    HostName example.com
    User elssar
    IdentityFile ~/.ssh/id_example
    PreferredAuthentications publickey
我的ssh配置中的条目如下所示

我正在使用
Fabric 1.10.1
Paramiko 1.14.1
Python 2.7.3
Ubuntu 12.04

编辑-结构存储库中存在相关的未解决问题-

编辑-我的文件的基本结构,以及我如何运行它

from fabric.api import env, run

def do_something():
    run("echo test")

def setup(host):
    env.hosts = [host]


# command
fab server:hostname do_something

我试图检查我的设置;以下是我对调试所做的操作:

>>> from fabric.network import key_filenames
>>> key_filenames()
[]
>>> from fabric.state import env
>>> env.use_ssh_config = True
>>> env.host_string = 'salt-states'
>>> key_filenames()
['/Users/damien/.ssh/salt.rsa.priv']
更新:您可以更新FAB文件以检测任务:

from fabric.api import env, run
from fabric.network import key_filenames

def do_something_debug():
    env.use_ssh_config = True
    print key_filenames()
    run("echo test")

def server(host):
    env.hosts = [host]
然后运行命令

fab server:hostname do_something_debug

我不能用完全相同的方法复制这个versions@goncalopp这很奇怪:/python是什么版本的?
python2.7.6
在debian-jessie上强制
ssh
使用相同的配置文件时会发生什么?例如,
#ssh-F path/to/config示例
。你有类似的行为吗?当我使用shell时,它会找到正确的密钥,但是当运行我的fabfile时,我仍然会得到相同的bug。哼,奇怪。它会打印正确的密钥文件名,但仍然会随机遍历密钥,而不是使用正确的密钥。您可以尝试检查
/etc/hosts
,查看您的配置是否使用不同的密钥多次引用同一主机。在我的
/etc/hosts
中,除了默认内容外,没有其他内容