Ansible-Linux_Base/roles/base/tasks/core_ssh.yml

63 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2021-09-01 17:31:49 -06:00
---
# file: roles/base/tasks/core_ssh.yml
- name: Install the issue notice
template:
src: issue.j2
dest: /etc/issue
notify: Restart SSH
tags:
- issue
- name: Configure SSH to display the issue notice
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?Banner '
line: Banner /etc/issue
notify: Restart SSH
tags:
- issue
- name: Setup authorized keys
authorized_key:
user: "{{ base_core_management_user }}"
state: present
key: '{{ lookup("file", item) }}'
with_fileglob:
- "public_keys/*"
tags:
- authorized_key
- name: Setup authorized keys for secondary user
authorized_key:
user: "{{ base_core_secondary_user }}"
state: present
key: '{{ lookup("file", item) }}'
with_fileglob:
- "public_keys/*"
when: base_core_secondary_user != ""
tags:
- authorized_key
2021-09-01 17:31:49 -06:00
- name: Configure SSH root login
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PermitRootLogin '
line: PermitRootLogin no
when: base_core_ssh_permit_root_login == false
notify:
- Restart SSH
tags:
- root_login
- name: Configure SSH password auth
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PasswordAuthentication '
line: PasswordAuthentication no
when: base_core_ssh_permit_password_authentication == false
notify:
- Restart SSH
tags:
- password_auth