This is more of a Unix question than an ansible question.

Your login ID should not be root.
Your sudo file ,on destination host, should have your login ID defined with
appropriate permissions.
Use ssh keys for your login ID

Hope this helps.

On Wed, Mar 17, 2021 at 03:37 reredok <[email protected]> wrote:

> Hello,
> i tried everything possible with "become" in the playbook:
>
> Either the password is wrong or a password is needed.
>
> To rule out that I have a problem with root, I temporarily set
> PermitRootLogin Yes in /etc/ssh/sshd_config and then it works.
>
> I have looked at the ansible documentation which I may not understand in
> full. Again for understanding:
>
> There is an "ansible_user" who connects remotely via ssh and I give him
> the password in the "Inventory" with ansible_ssh_pass. In the "playbook" I
> set "become: yes"," become_user: root", "become_method: sudo". This then
> changes the ssh user to root and runs my "apt:" command.
>
> Do you have an example that works for you? Thanks a lot
>
>
>
> [email protected] schrieb am Dienstag, 16. März 2021 um 21:22:36 UTC+1:
>
>> Explained in detail here
>> https://docs.ansible.com/ansible/latest/user_guide/become.html
>>
>> On Tue, 16 Mar 2021 at 21:13, Mike Eggleston <[email protected]> wrote:
>>
>>> Use “become”.
>>>
>>>
>>> On Mar 16, 2021, at 14:54, reredok <[email protected]> wrote:
>>>
>>> Hello all,
>>>
>>> one thing is not clear to me about ansible. On all my Linux VM the root
>>> ssh access, for security reasons, is blocked. So the ad-hoc, playbook
>>> access only works via a non-administrative user. But then, for example, to
>>> install something on the Linux VM, how do you change the user to root? I
>>> don't want to work with ssh and public keys in my small environment and the
>>> root ssh access should remain closed.
>>> Thanks for any feedback
>>>
>>> reredok
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/869e69b8-67b2-475d-b06a-10f287d54de2n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/869e69b8-67b2-475d-b06a-10f287d54de2n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/33BF877F-88A3-48B1-ABD4-67A701B2AA38%40gmail.com
>>> <https://groups.google.com/d/msgid/ansible-project/33BF877F-88A3-48B1-ABD4-67A701B2AA38%40gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>
>>
>>> --
>> Sent from a mobile device - please excuse the brevity, spelling and
>> punctuation.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d2404f8c-8626-4bd8-88d6-4dd9f7a9a143n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d2404f8c-8626-4bd8-88d6-4dd9f7a9a143n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Thanks,
MJ Barber

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFVMVpmxULgBkCAD3QfrqV5%2BGnY02y4ru_4%3DhH%2BqPz-e3K-Guw%40mail.gmail.com.

Reply via email to