3

The following fabric script is open source which I need to use, unfortunately I'm not familiar with this stuff. The fabric file starts with:

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))

The fabric file is run by a Jenkins server when a new build is triggered by a Git push. When this file is executed this first remote action (last line) results in the following error.

/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 [email protected]: ===> 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

Do I have to specify a password for the aegir user or so? I tried to include env.password = '' (I deleted the Aegir's user password with passwd --delete aegir on my remote machine) under env.user = 'aegir', but that didn't solve anything.

3 Answers 3

2

Ssh service forbid remote access for users without password. You can just set password for aegir user, on machine and in a fabfile.

1
  • Okay, that was the problem indeed. Stupid I didn't try that. Thanks!
    – jroeleveld
    Oct 14, 2012 at 11:51
1

Login required. To avoid interactivity, you can copy the public key from the FABRIC machine and paste in the TARGET machine's ~/.ssh/authorized_keys

Make sure that: Not to include or exclude anything that's not the key (like introduce linefeeds), the key must be copied exactly as is.

and do this:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh/*
1
  • 1
    what if all of the above fail?
    – Max
    Dec 10, 2015 at 11:29
0

Use this function and bomb!

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. Do not pass list of the keys to env.key_filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.