Files
homeserver.zernis.ch/roles/defaults/tasks/ssh-config.yml
2023-03-20 16:03:41 +01:00

23 lines
630 B
YAML

---
- name: Add Authorized Keys
ansible.posix.authorized_key:
user: "{{ user['name'] }}"
state: present
key: "{{ lookup('file', 'simon_win11.pub') }}"
- name: Harden SSH Config
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
validate: 'sshd -T -f %s'
mode: '0644'
with_items:
- regexp: "^PasswordAuthentication"
line: "PasswordAuthentication no"
- regexp: "^Port"
line: "Port {{ ssh_port }}"
- regexp: "^PermitRootLogin"
line: "PermitRootLogin without-password"
notify: Restart ssh