blob: 2a410f5bff2cd56754d3de43152dbe3f250532f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
---
- hosts: all
gather_facts: false
tasks:
- name: ensure SSH login with password is disabled
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication"
line: PasswordAuthentication no
state: present
become: yes
notify:
- restart ssh
- name: Set authorized key taken from file
ansible.posix.authorized_key:
user: "{{ ansible_ssh_user }}"
state: present
key: "{{ lookup('file', item) }}"
with_items:
- keys/benbrown.pub
handlers:
- name: restart ssh
service:
name: ssh
state: restarted
become: yes
|