I have fab file which contains
env['hosts'] = ['localhost']
env['user'] = 'code'
env['password'] = 'searce'
def mk_dirtree():
sudo("mkdir %s" % PROJECT_DIR)
sudo("chown -R code:code %s" % PROJECT_DIR)
run("mkdir -p %s" % (PROJECT_DIR + '/www/static'))
sudo("chown -R www-data:www-data %s" % (PROJECT_DIR + '/www'))
now when I do fab mk_dirtree
I am constantly prompt for [localhost] Login password for 'code':
I am running this on an ec2 instance to which I am connecting via ssh using key, and password login for ssh is disabled
EDIT:
I think fabric is first doing ssh code@localhost
but that wont work since password sshing is disabled
If you really want and need to use
run()
instead oflocal()
you can add your SSH public key to the~/.ssh/authorized_keys
file of your user account.This would look something like this:
This solution will circumvent the login password prompt of your local machine. Of course, you'd have to do this for each local machine where you run your fabfile on.
The
run()
andsudo()
operations are carried out via ssh. If you want to run a command on the localhost you should look into usinglocal()
instead:http://docs.fabfile.org/en/1.4.3/api/core/operations.html?highlight=sudo#fabric.operations.local
On that same page are the docs for
run()
andsudo()
which both refer to the fact they run on a "remote host" which infers that they will be run via ssh.