2018-03-07 03:28:23 +01:00
|
|
|
---
|
2018-11-16 11:44:36 +01:00
|
|
|
|
|
|
|
- name: register os-specific variables
|
|
|
|
include_vars: default.yml
|
|
|
|
when: ansible_distribution != 'Fedora'
|
|
|
|
|
|
|
|
- name: register os-specific variables
|
|
|
|
include_vars: "{{ ansible_distribution }}.yml"
|
|
|
|
when: ansible_distribution == 'Fedora'
|
|
|
|
|
|
|
|
|
2018-03-16 04:54:02 +01:00
|
|
|
- name: Collect all users and groups allowed to login via ssh
|
|
|
|
set_fact:
|
2018-11-16 11:44:36 +01:00
|
|
|
sshd_allow_users: '{{ ["root", "ansible"] + users.keys() | default({}) | sort }}'
|
|
|
|
sshd_allow_groups: '{{ ["root", "admins"] + users.keys() | default({}) | sort }}'
|
2018-03-16 04:54:02 +01:00
|
|
|
|
|
|
|
|
2018-03-07 03:28:23 +01:00
|
|
|
- name: Copy sshd configuration
|
|
|
|
template:
|
|
|
|
src: sshd_config
|
|
|
|
dest: '/etc/ssh/sshd_config'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 'u=rw,g=r,o=r'
|
|
|
|
validate: /usr/sbin/sshd -t -f %s
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
|
|
|
|
|
|
|
|
|
|
|
- name: Generate new ed25519 ssh host key pair if necessary
|
|
|
|
command: ssh-keygen -t ed25519 -f 'ssh_host_ed25519_key' -P '' -q
|
|
|
|
args:
|
|
|
|
chdir: '/etc/ssh/'
|
|
|
|
creates: 'ssh_host_ed25519_key.pub'
|
|
|
|
notify:
|
|
|
|
- restart ssh
|
2018-03-07 03:28:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
- name: Remove unwanted host keys
|
|
|
|
file:
|
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- ecdsa
|
|
|
|
- rsa
|
|
|
|
- dsa
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-01-08 14:12:27 +01:00
|
|
|
|
2018-03-07 03:28:23 +01:00
|
|
|
- file:
|
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key.pub'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- ecdsa
|
|
|
|
- rsa
|
|
|
|
- dsa
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
2018-11-16 11:44:36 +01:00
|
|
|
|