2017-08-16 57 views
-2

在我的Linux机器上,系统中有三个用户级别。ansible switch user to sudo

- base_user 
- higher_user 
- root 

我通过SSH远程连接到机器的base_user级别。 我的ssh密钥设置让我可以自动作为base_user登录。 然后我想更改为没有sudo权限的higher_user。 根据安全文档(http://docs.ansible.com/ansible/latest/become.html),成为并且become_user需要在base_user上使用sudo才能成为higher_user。 我不想让higher_user或base_user具有sudo特权。

是否有任何解决方法,只是纯粹做下面的ansible?

1. login as base_user with ssh key setup 
2. switch user to higher_user with password input 
+0

你叫什么“sudo用户”?可以sudo root的用户?还要别的吗? –

回答

0

sudoers文件中的此行将允许base_user使用sudo以higher_user身份运行命令。它不会允许base_user以root或任何其他用户身份运行命令。

base_user ALL=(higher_user) ALL 

从那里,你可以在你的剧本使用becomebecome_user

- hosts: some_host 
    become: True 
    become_user: higher_user 
    tasks: 
... 

当你运行ansible-playbook您将需要提供base_user的密码与--ask-become-pass-K)。