Getpass错误

时间:2012-10-13 11:06:01

标签: python fabric

以下结构脚本是我需要使用的开源脚本,遗憾的是我不熟悉这些东西。结构文件以:

开头
from fabric.api import *
import time

env.user = 'aegir'
env.shell = '/bin/bash -c'

# Download and import a platform using Drush Make
def build_platform(site, profile, webserver, dbserver, makefile, build):
  print "===> Building the platform..."
  run("drush make %s /var/aegir/platforms/%s" % (makefile, build))

当Git推送触发新构建时,结构文件由Jenkins服务器运行。执行此文件时,第一个远程操作(最后一行)会导致以下错误。

/usr/lib/python2.6/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password for aegir@o1.sub.aegir.local: ===> Building the platform...
[o1.sub.aegir.local] run: drush make https://raw.github.com/mig5/builds/master/mig5_platform.build /var/aegir/platforms/20121011010955
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/fabric/main.py", line 435, in main
    commands[name](*args, **kwargs)
  File "/usr/local/bin/fabfile.py", line 11, in build_platform
    run("drush make %s /var/aegir/platforms/%s" % (makefile, build))
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 390, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/fabric/operations.py", line 414, in run
    channel = connections[env.host_string]._transport.open_session()
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 65, in __getitem__
    self[real_key] = connect(user, host, port)
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 219, in connect
    password = prompt_for_password(password, text)
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 279, in prompt_for_password
    new_password = getpass.getpass(password_prompt)
  File "/usr/lib/python2.6/getpass.py", line 83, in unix_getpass
    passwd = fallback_getpass(prompt, stream)
  File "/usr/lib/python2.6/getpass.py", line 118, in fallback_getpass
    return _raw_input(prompt, stream)
  File "/usr/lib/python2.6/getpass.py", line 135, in _raw_input
    raise EOFError
EOFError
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我是否必须为aegir用户指定密码?我尝试在env.password = ''下添加passwd --delete aegir(我在我的远程计算机上删除了env.user = 'aegir'的Aegir用户密码),但这并没有解决任何问题。

3 个答案:

答案 0 :(得分:2)

Ssh服务禁止没有密码的用户进行远程访问。您只需在aegir用户,机器和fabfile中设置密码。

答案 1 :(得分:1)

需要登录。为了避免交互性,您可以从FABRIC机器复制公钥并粘贴到TARGET机器的〜/ .ssh / authorized_keys

确保: 不包括或排除任何不是密钥的东西(如引入换行符),密钥必须完全按原样复制。

并执行此操作:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh/*

答案 2 :(得分:0)

使用此功能并炸弹!



output['running']  = False     # Avoid fabric to output what it is doing behind the scenes
output['stdout']   = False     # Do not show stdout
output['stderr']   = False     # Do not show stderr
output['status']   = False     # Prevent fabric from using print in some situations (at least in disconnect_all)
output['warnings'] = False     # Avoid fabric from showing messages about failed commands

def run_it(command, user, host, port, keyfile):
    env.host_string = "%s@%s:%s" % (user, host, port)
    env.key_filename = keyfile
    try:
        res = run(command, pty=False, shell=True)
        print "SUCCESS: return_code=%s" % (return_code)
    except Exception, e:
        print "ERROR  : %s" % (e)
        stdout, return_code =  None, None
    return stdout, return_code




P.S。不要将键列表传递给env.key_filename