【发布时间】:2020-12-28 15:21:11
【问题描述】:
在我的公司,我们有有限的 root 访问权限,通过这种方式在 sudoers.d 上:
user hostname =(root) PASSWD: /bin/su
我正在尝试使 ansible 模仿:
all:
vars:
ansible_connection: ssh
ansible_become: true
ansible_become_pass: 'password'
become_flags: '/bin/su - root /bin/bash -c'
worker:
hosts:
hostname
但是,我所做的每一个证明都以这个错误结束:
hostname | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "Shared connection to hostname closed.\r\n",
"module_stdout": "\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
我已阅读有关权限升级和受限 sudo 的信息: ansible privilege escalation
但是,在主机上,我们可以通过这种方式启动任何 sudo 命令:
sudo su -s /bin/sh -c "ls"
有没有办法让ansible使用这种方法还是不可能?
谢谢
【问题讨论】:
-
只检查这里:你唯一能做的就是通过
/bin/su成为root,你需要密码吗?