面料不断询问密码 [英] fabric keeps asking for password

查看:73
本文介绍了面料不断询问密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含的fab文件

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

现在,当我执行fab mk_dirtree时,我会不断提示输入[localhost] Login password for 'code':

now when I do fab mk_dirtree I am constantly prompt for [localhost] Login password for 'code':

我正在使用密钥通过ssh通过SSH连接到的ec2实例上运行此命令,并且ssh的密码登录已禁用

I am running this on an ec2 instance to which I am connecting via ssh using key, and password login for ssh is disabled

我认为Fabric首先要执行ssh code@localhost,但是由于禁用了密码sshing,因此无法正常工作

I think fabric is first doing ssh code@localhost but that wont work since password sshing is disabled

推荐答案

如果您确实需要使用run()而不是local(),则可以将SSH公钥添加到用户帐户的~/.ssh/authorized_keys文件中

If you really want and need to use run() instead of local() you can add your SSH public key to the ~/.ssh/authorized_keys file of your user account.

这看起来像这样:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

此解决方案将绕过本地计算机的登录密码提示.当然,您必须在运行fabfile的每台本地计算机上执行此操作.

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.

这篇关于面料不断询问密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆