2022-12-22 19:18:27 +00:00
|
|
|
# vim: ft=yaml.ansible
|
|
|
|
---
|
|
|
|
- name: Add public SSH key to default user
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.posix.authorized_key:
|
2022-12-22 19:18:27 +00:00
|
|
|
user: "{{ ansible_user }}"
|
|
|
|
key: "{{ ssh_key }}"
|
|
|
|
exclusive: true
|
|
|
|
|
|
|
|
- name: Allow SSH login with public keys
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.lineinfile:
|
2022-12-22 19:18:27 +00:00
|
|
|
regexp: '^#?PubkeyAuthentication '
|
|
|
|
line: PubkeyAuthentication yes
|
|
|
|
dest: /etc/ssh/sshd_config
|
2022-12-31 14:53:24 +00:00
|
|
|
notify: sshd
|
2022-12-22 19:18:27 +00:00
|
|
|
|
|
|
|
- name: Disallow SSH login with password
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.lineinfile:
|
2022-12-22 19:18:27 +00:00
|
|
|
regexp: '^#?PasswordAuthentication '
|
|
|
|
line: PasswordAuthentication no
|
|
|
|
dest: /etc/ssh/sshd_config
|
2022-12-31 14:53:24 +00:00
|
|
|
notify: sshd
|
2022-12-22 19:18:27 +00:00
|
|
|
|
|
|
|
- name: Disallow root login over SSH
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.lineinfile:
|
2022-12-22 19:18:27 +00:00
|
|
|
regexp: '^#?PermitRootLogin '
|
|
|
|
line: PermitRootLogin no
|
|
|
|
dest: /etc/ssh/sshd_config
|
2022-12-31 14:53:24 +00:00
|
|
|
notify: sshd
|