Files
ssh-protect/tasks/main.yml
2024-02-25 20:27:42 +00:00

21 lines
518 B
YAML

---
- name: Write ssh keys
template:
src: "authorized_keys.j2"
dest: "/root/.ssh/authorized_keys"
mode: 0600
- name: Authentication method public key only
lineinfile:
path: /etc/ssh/sshd_config
search_string: '^#?AuthenticationMethods'
line: AuthenticationMethods publickey
notify: restart sshd
- name: Disable password authentication
lineinfile:
path: /etc/ssh/sshd_config
search_string: '^#?PasswordAuthentication'
line: PasswordAuthentication no
notify: restart sshd