2020-03-12 09:46:58 +00:00
|
|
|
---
|
|
|
|
- name: Disable SSH passwords
|
|
|
|
become: true
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/ssh/sshd_config
|
|
|
|
regexp: '^#?\w*PasswordAuthentication (yes|no)'
|
|
|
|
line: 'PasswordAuthentication no'
|
|
|
|
register: changed_ssh_config
|
|
|
|
- name: Enable SSH
|
|
|
|
become: true
|
|
|
|
systemd:
|
|
|
|
name: sshd.service
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
- name: Restart SSH
|
|
|
|
become: true
|
|
|
|
systemd:
|
|
|
|
name: sshd.service
|
|
|
|
state: restarted
|
|
|
|
when: changed_ssh_config.changed == true
|
2020-03-12 09:52:54 +00:00
|
|
|
- name: Allow SSH through firewall
|
|
|
|
become: true
|
|
|
|
firewalld:
|
|
|
|
service: ssh
|
|
|
|
permanent: yes
|
|
|
|
state: enabled
|
|
|
|
immediate: yes
|