Skip to main content
 首页 » 编程设计

python之为什么我在使用 fabric 时会收到提示

2025年05月04日11wayfarer

当我尝试使用 fabric 时,它会在我进行身份验证后为我提供一个远程 shell。然后当我退出时,结构任务运行。这是为什么?

这是我收到的输出:

user@locahost:~$ fab -H remote_host mytask 
[remote_host] Executing task 'mytask' 
[remote_host] run: python --version 
[remote_host] Login password:  
[remote_host] out: user@remote_host:~>exit 
[remote_host] out: exit 
[remote_host] out: Could not open a connection to your authentication agent. 
[remote_host] out: Python 2.6.4 
[remote_host] out:  
 
Done. 
Disconnecting from remote_host... done. 

登录后,我立即收到以下提示 user@remote_host:~>,我必须手动退出。

fabfile.py的内容:

from fabric.api import run 
 
def mytask(): 
    run("python --version") 

顺便说一句,我使用的是 fabric 1.2 版。

请您参考如下方法:

Could not open a connection to your authentication agent. 告诉我它正在寻找 ssh-agent 或类似的东西。查看您要连接的主机的 .login/.profile/.bash_profile 以查找问题。此外,尝试手动启动 SSH 连接,看看是否会给出任何提示。