workstation/roles/arch/tasks/ssh.yml

21 lines
452 B
YAML
Raw Normal View History

2020-04-07 14:20:27 +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