authorized_keys module

24 views
Skip to first unread message

Chris Bidwell - NOAA Federal

unread,
Feb 6, 2019, 2:11:29 PM2/6/19
to ansible...@googlegroups.com
Hi all,

I'm trying to add pubkeys to several users and I'm getting an error message.  Here's the playbook:

---
- name: Add users and pubkeys
  hosts: server1
  become: yes
  vars_files:
    - passwd.yml
    - vars.yml

  tasks:
    - name: "Add users to gong server"
      user:
        name: "{{ item.name }}"
        comment: "{{ item.comment }}"
        shell: /bin/bash
      with_items:
        - { name: "user1", comment: "user1" }
        - { name: "user2", comment: "user2" }
        - { name: "user3", comment: "user3" }
        - { name: "user4", comment: "user4" }

    - name: "Copy public keys"
      authorized_key:
        user: "{{ item.user }}"
        state: present
        key: "{{ lookup('file', 'files/pubkey/{{ item.key }}') }}"
      with_items:
        - { user: "user1", key: "user1.pub" }

Here's the error:
TASK [Copy public keys] **********************************************************************************************************************************
failed: [server1] (item={u'user': u'user1', u'key': u'user1.pub'}) => {"changed": false, "item": {"key": "user1.pub", "user": "user1"}, "msg": "invalid key specified: TIcN+b2YbI4EzQcthGikJIkR83spy4hr0JWklq89HHMYZ1XT8rj8bwRf33hQ91oleE4YvzzZh5YKuk+QgEAvXJeXQQxvhdbZ"}

Kai Stian Olstad

unread,
Feb 6, 2019, 2:58:04 PM2/6/19
to ansible...@googlegroups.com
On 06.02.2019 20:11, 'Chris Bidwell - NOAA Federal' via Ansible Project
wrote:
How does you pub files look like, this key does looks too short?
You can also check pub files with
ssh-keygen -l -f files/pubkey/user1.pub

--
Kai Stian Olstad

Dick Visser

unread,
Feb 6, 2019, 2:58:50 PM2/6/19
to ansible...@googlegroups.com
Could it be that the key value has to start with the type of the key?
I.e. "ssh-rsa" ?
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAHKi8CjXHBXykAL7dwrPsXQOvb3KwF6A%2BRbdkkN%3Dmy%3DDXHF5Pw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages