# vim: ft=yaml.ansible
---
- name: Add public SSH key to default user
authorized_key:
user: "{{ ansible_user }}"
key: "{{ ssh_key }}"
exclusive: true
- name: Allow SSH login with public keys
lineinfile:
regexp: '^#?PubkeyAuthentication '
line: PubkeyAuthentication yes
dest: /etc/ssh/sshd_config
notify: Restart sshd
- name: Disallow SSH login with password
regexp: '^#?PasswordAuthentication '
line: PasswordAuthentication no
- name: Disallow root login over SSH
regexp: '^#?PermitRootLogin '
line: PermitRootLogin no