给用户配置Sudo(免密)
错误日志We trust you have received the usual lecture from the local SystemAdministrator根本原因是mysql用户去执行脚本中的sudo命令时权限不够,所以我们需要为其配置sudo权限并加上免密配置。① 使用su命令切换超级用户(root用户)② 我们需要在sudoers配置文件中修改,所以先为该文件配置写权限:chmod
·
原文:https://www.jianshu.com/p/5bf1fe9c6483
为用户配置sudo权限并加上免密配置。
① 使用su命令切换超级用户(root用户)
② 我们需要在sudoers配置文件中修改,所以先为该文件配置写权限:
chmod u+w /etc/sudoers // 给/etc下的sudoers文件加上write权限
③ 进入sudoers文件,加上对应用户的配置语句:
vi /etc/sudoers //进入文件后找到## Allows people in group wheel to run all commands
找到该句
## Allows people in group wheel to run all commands
④ 配置用户sudo免密权限。按i进入insert模式,在root ALL=(ALL) ALL下方加上:
[你需要配置的用户名] ALL = (ALL) ALL //在sudo的时候需要输入密码
或
[你需要配置的用户名] ALL = (ALL) NOPASSWD:ALL //在sudo的时候不需输入密码
然后esc退出insert模式,按冒号后输入wq保存退出。
配置好后如图
![在这里插入图片描述](https://img-blog.csdnimg.cn/b9d6d41e26334c84a3871672579e01a6.png)
⑤ 为了安全考虑移除sudoers文件的写权限:
chmod u-w /etc/sudoers //移除sudoers的写权限
更多推荐
已为社区贡献2条内容
所有评论(0)