Fabric Sudo无密码解决方案 [英] Fabric Sudo No Password Solution

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

问题描述

此问题与最佳做法有关。我正在使用Fabric运行部署脚本。我的部署用户部署需要sudo才能重新启动服务。因此,我正在使用Fabric中的sudo函数在脚本中运行这些命令。这可以正常工作,但在脚本执行期间提示输入密码。我不想在部署期间输入密码。这里的最佳做法是什么。我能想到的唯一解决方案是更改sudo权限,以使部署用户运行的命令不需要密码。

This question is about best practices. I'm running a deployment script with Fabric. My deployment user 'deploy' needs sudo to restart services. So I am using the sudo function from fabric to run these commands in my script. This works fine but prompts for password during script execution. I DON'T want to type a password during deployments. What's the best practice here. The only solution I can think of is changing the sudo permissions to not require password for the commands my deployment user runs. This doesn't seem right to me.

推荐答案

正如Bartek所建议的那样,为部署用户启用无密码sudo。在sudoers文件中。

As Bartek also suggests, enable password-less sudo for the deployment 'user' in the sudoers file.

类似的东西:

run('echo "{0} ALL=(ALL) ALL" >> /etc/sudoers'.format(env.user))

这篇关于Fabric Sudo无密码解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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