Files
ansible_linux_setup/roles/ssh/tasks/main.yml
2021-02-28 21:30:03 +00:00

35 lines
753 B
YAML

---
- name: Remove any PermitRootLogin instruction
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PermitRootLogin"
state: absent
notify: restart ssh
- name: Disable SSH root login
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PermitRootLogin"
line: "PermitRootLogin prohibit-password"
state: present
notify: restart ssh
- name: Disable password authentication
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no"
state: present
notify: restart ssh
- name: Set SSH port
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^Port"
line: "Port {{sshd_port}}"
state: present
notify: restart ssh
- name: Test
lineinfile