0
  • Default ansible 2.9 configuration.

  • User user exists both on the control and the hosts.

  • Control and hosts have each other's ssh public keys for both users.

From the control host:

root$ ansible all -a "echo whatever" works

user$ ansible all -a "echo whatever" works

user$ ansible all -a "echo whatever" -u root doesn't work.

Error: ... Failed to connect to the host via ssh: root@xhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password) ...

I tried using --become* with no success. How to make that work? what am I missing?

2
  • root$ ansible all -a "echo whatever" -u user also works
    – Katerl3s
    May 4, 2021 at 1:53
  • user has user ALL = (ALL) NOPASSWD: ALL sudo configuration
    – Katerl3s
    May 4, 2021 at 2:09

2 Answers 2

1

Make sure you have root credentials of all remote hosts. You can copy them to your host using ssh-copy-id for example.

1
  • The question reads "Control and hosts have each other's ssh public keys for both users."
    – Katerl3s
    May 5, 2021 at 0:21
0

user$ sudo ansible all -a "echo whatever" -u root

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .