Skip to content

Commit

Permalink
gpg: write public ssh key
Browse files Browse the repository at this point in the history
  • Loading branch information
dezeroku committed Nov 26, 2023
1 parent ac60e79 commit c2d2e54
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions roles/gpg/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,27 @@
stdin: "trust\n5\ny\n"
changed_when: true
when: gpg_key_is_trusted.rc != 0

- name: Ensure ssh directory exists
become: true
become_user: "{{ user_name }}"
ansible.builtin.file:
path: ~/.ssh
state: directory
mode: 0700

- name: Obtain ssh public key
become: true
become_user: "{{ user_name }}"
ansible.builtin.command:
cmd: gpg --export-ssh-key "0x{{ user_gpg_key }}"
changed_when: false
register: gpg_ssh_key

- name: Write ssh public key
become: true
become_user: "{{ user_name }}"
ansible.builtin.copy:
content: "{{ gpg_ssh_key.stdout }}"
dest: ~/.ssh/id_smartcard_{{ user_name }}.pub
mode: 0644

0 comments on commit c2d2e54

Please sign in to comment.