workstation/roles/distro/tasks/ssh.yml

21 lines
434 B
YAML
Raw Normal View History

2019-10-05 19:33:23 +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
2019-10-10 18:45:35 +00:00
service:
name: ssh
2019-10-05 19:33:23 +00:00
enabled: yes
state: started
- name: Restart SSH
become: true
2019-10-10 18:45:35 +00:00
service:
name: ssh
2019-10-05 19:33:23 +00:00
state: restarted
when: changed_ssh_config.changed == true