sshd_cert: First version of role
This commit is contained in:
parent
df2573a650
commit
7ce6d58923
3 changed files with 47 additions and 0 deletions
|
@ -48,6 +48,7 @@
|
||||||
- pki
|
- pki
|
||||||
- psacct
|
- psacct
|
||||||
- sshd
|
- sshd
|
||||||
|
- sshd_cert
|
||||||
- node_exporter
|
- node_exporter
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: role
|
loop_var: role
|
||||||
|
|
3
roles/sshd_cert/meta/main.yml
Normal file
3
roles/sshd_cert/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- {role: sshd}
|
43
roles/sshd_cert/tasks/main.yml
Normal file
43
roles/sshd_cert/tasks/main.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
- name: Copy public key for signing
|
||||||
|
ansible.builtin.fetch:
|
||||||
|
src: /etc/ssh/ssh_host_ed25519_key.pub
|
||||||
|
dest: "/srv/sshca/pubkeys/{{ inventory_hostname }}.pub"
|
||||||
|
flat: true
|
||||||
|
|
||||||
|
- name: Sign key
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- ssh-keygen
|
||||||
|
- -s
|
||||||
|
- /srv/sshca/ca/ca
|
||||||
|
- -I
|
||||||
|
- "{{ inventory_hostname }}"
|
||||||
|
- -h
|
||||||
|
- -n
|
||||||
|
- "{{ inventory_hostname }}"
|
||||||
|
- -V
|
||||||
|
- -1h:+365d
|
||||||
|
- -z
|
||||||
|
- "{{ ansible_date_time.epoch }}"
|
||||||
|
- "/srv/sshca/pubkeys/{{ inventory_hostname }}.pub"
|
||||||
|
creates: "/srv/sshca/pubkeys/{{ inventory_hostname }}-cert.pub"
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Install certificate
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/ssh/ssh_host_ed25519_key-cert.pub
|
||||||
|
src: "/srv/sshca/pubkeys/{{ inventory_hostname }}-cert.pub"
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: "{{ ansible_wheel }}"
|
||||||
|
notify: Restart sshd
|
||||||
|
|
||||||
|
- name: Enable host certificate
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/ssh/sshd_config
|
||||||
|
line: HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
|
||||||
|
regexp: "^(# )?HostCertificate .*"
|
||||||
|
insertafter: "^HostKey .*"
|
||||||
|
validate: "sshd -t -f %s"
|
||||||
|
notify: Restart sshd
|
Loading…
Add table
Add a link
Reference in a new issue