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