python - 提示输入密码时结构任务错误

标签 python fabric paramiko

我有一个错误,我似乎无法通过。我有一个简单的结构任务,必须在远程系统上以不同的用户身份运行,例如:

def update():
    env.user = 'otheruser'
    #~ env.password = 'otherpass'  # this works, but I don't want it here.
    with cd(env.sitefolder):
        run('hg pull -u')

如果我使用硬编码的 env.password 运行它,它就可以工作。如果我使用 fab -p otherpass update 它也可以。如果我省略它 the docs说我会得到提示。这是真的,但它不起作用。每次输入密码后,我都会收到此错误:

> fab dev update
[darkstar] Executing task 'update'
[darkstar] run: hg pull -u
[darkstar] Login password: 
ERROR:paramiko.transport:Exception: Error reading SSH protocol banner
...
Fatal error: Error reading SSH protocol banner

Aborting.

在 Ubuntu Natty 上使用 fabric 1.2.2。我也尝试了 env.no_keys 选项,但它没有改变任何东西。谁能帮忙?

最佳答案

自己提示输入密码!

def update():
    env.user = 'otheruser'
    env.password = getpass.getpass('Enter password: ')
    with cd(env.sitefolder):
        run('hg pull -u')

getpass 是标准库的一部分,它只是一个 raw_input,不会回显您输入的内容

关于python - 提示输入密码时结构任务错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7732856/

相关文章:

python - 从折线图中删除小数

python - 使用一个函数中的变量到另一个函数中

python - 在 Windows 上安装 Fabric(Python 库)时出现 "error: Unable to find vcvarsall.bat"

python - 如何使用 python 结构发送流

python - 将 python 字典附加到 csv

python - 面试题: find the direction of first step

python - 如何将 boolean 参数传递给结构命令

python - 使用 Paramiko 组合交互式 shell 和 receive_exit_status 方法

python - 使用 Paramiko 读取 Top 命令的输出

python - Paramiko 无法获得 grep 命令的输出