Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding public key via playbook only succeeds, when the path is set - even if its the default in the userprofile/ Root/.ssh/authorized_keys #532

Open
5 of 11 tasks
gsg-git opened this issue Feb 26, 2024 · 2 comments

Comments

@gsg-git
Copy link

gsg-git commented Feb 26, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to [email protected] instead.)

Bug Summary

My playbook gets marked as successfully executed, but there are no entrys in any authorized_keys files.
After trying to set a custom path where the content of the public key gets added the playbook did add the line in the custom path.
Then i tried my (default?) path at /root/.ssh/authorized_keys and the key got added there too.
I got requested to report the bug from the Ansible forum:
https://forum.ansible.com/t/default-code-to-add-public-ssh-key-fails/3702/34

AWX version

AWX 23.6.0

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

Ubuntu server 22

Web browser

No response

Steps to reproduce

`---

  • name: Set authorized keys
    hosts: all
    gather_facts: false
    vars:
    key_url: "https://raw.githubusercontent.com/gsg-git/awx_pub/main/awxtestpub"
    key_content: "{{ lookup('url', key_url, split_lines=false) }}"
    conversion_cmd: 'ssh-keygen -i -m RFC4716 -f /dev/stdin <<<"{{ key_content }}"'
    new_key_content: "{{ lookup('pipe', conversion_cmd) }}"

    tasks:

    • name: Set authorized keys taken from url
      ansible.posix.authorized_key:
      user: root
      state: present
      key: "{{ new_key_content }}"
      Here i have to add at the end:path: /root/.ssh/authorized_keys`

Expected results

Adding the ssh key at the default location without further config

Actual results

i have to add the path even the default ones.

Additional information

Links for the successfull job log:
https://github.com/gsg-git/awx_pub/blob/main/job_237.txt
link for the false positive log where nothing gets entered:
https://github.com/gsg-git/awx_pub/blob/main/job_263-falsepositive.txt

@gsg-git
Copy link
Author

gsg-git commented Feb 26, 2024

I have been told to open the issue here from the regular AWX Git:
ansible/awx#14883

@s-hertel
Copy link
Contributor

This is where I asked you to file the issue originally. But, as we previously discussed, your claim is not reproducible (so it's probably a mistake on your end testing, rather than a bug in the module). From https://forum.ansible.com/t/default-code-to-add-public-ssh-key-fails/3702/37:

If you open an issue at Issues · ansible-collections/ansible.posix · GitHub 1 please be sure to include a simple generic reproducer, the full output with -vvv, and the commands you’re running that prove the module didn’t do what it claimed. I wasn’t able to reproduce the issue.

What commands are you running that make you think it's a false positive? From tracing the module just now I am quite sure it's not a bug, but please correct me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants