问题描述
我有包含的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.
这篇关于面料不断询问密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!