system/tasks/ssh.yml

44 lines
1.0 KiB
YAML
Raw Normal View History

2022-12-10 17:51:03 +00:00
- name: Ensure SSH instalation
2022-10-23 13:28:33 +00:00
become: true
2022-12-10 17:51:03 +00:00
ansible.builtin.package:
name: '{{ system_ssh_package }}'
2022-10-23 13:28:33 +00:00
state: present
2022-11-06 18:10:26 +00:00
2021-07-10 12:41:35 +00:00
2022-12-10 17:51:03 +00:00
- name: Ensure key directory exist
become: true
2022-12-10 17:51:03 +00:00
ansible.builtin.file:
state: directory
2022-12-10 17:51:03 +00:00
path: '{{ item.keyfile | dirname }}'
owner: '{{ item.user }}'
2021-07-10 12:41:35 +00:00
mode: 0700
2022-12-10 17:51:03 +00:00
with_items: '{{ privatekeytodeploy }}'
2020-03-01 20:06:02 +00:00
2021-04-20 08:18:56 +00:00
- name: Install ssh private key
2022-02-13 08:40:15 +00:00
become: true
2022-12-10 17:51:03 +00:00
ansible.builtin.copy:
content: '{{ item.privatekey }}'
dest: '{{ item.keyfile }}'
2021-04-20 08:18:56 +00:00
mode: 0600
2022-12-10 17:51:03 +00:00
owner: '{{ item.user }}'
with_items: '{{ privatekeytodeploy }}'
2020-03-01 20:06:02 +00:00
2020-03-02 20:19:09 +00:00
2022-12-10 17:51:03 +00:00
- name: Les connexions par mot de passe sont désactivées
2022-02-13 08:40:15 +00:00
become: true
2022-12-10 17:51:03 +00:00
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
2022-12-10 17:51:03 +00:00
regexp: '^#?PasswordAuthentication'
line: 'PasswordAuthentication no'
2020-03-02 20:19:09 +00:00
state: present
notify: Restart sshd
- name: Remove root SSH access
2022-02-13 08:40:15 +00:00
become: true
2022-12-10 17:51:03 +00:00
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
2022-12-10 17:51:03 +00:00
regexp: '^PermitRootLogin'
line: 'PermitRootLogin no'
2020-03-02 20:19:09 +00:00
state: present
notify: Restart sshd