aboutsummaryrefslogtreecommitdiffstats
path: root/roles/fedora/tasks/sshd.yml
blob: fc46c0769fe863db1187143bdc2db0c0c50617b3 (plain) (blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: Create private host keys
  copy:
    dest: '/etc/ssh/{{ item.key }}'
    content: '{{ item.value.private }}'
    owner: root
    group: ssh_keys
    mode: 0640
  with_dict: '{{ ssh_host_keys[hostname] }}'
  loop_control:
    label: '/etc/ssh/{{ item.key }}'
  when: ssh_host_keys is defined and hostname in ssh_host_keys

- name: Create public host keys
  copy:
    dest: '/etc/ssh/{{ item.key }}.pub'
    content: '{{ item.value.public }}'
    owner: root
    group: root
    mode: 0644
  with_dict: '{{ ssh_host_keys[hostname] }}'
  loop_control:
    label: '/etc/ssh/{{ item.key }}.pub'
  when: ssh_host_keys is defined and hostname in ssh_host_keys

- name: Configure SSH daemon
  lineinfile:
    path: '/etc/ssh/sshd_config'
    regexp: '{{ item.regexp }}'
    line: '{{ item.line }}'
  with_items:
  - regexp: '^#*PermitRootLogin'
    line: 'PermitRootLogin no'
  - regexp: '^#*PasswordAuthentication'
    line: 'PasswordAuthentication no'
  - regexp: '^#*GSSAPIAuthentication'
    line: 'GSSAPIAuthentication no'
  notify: restart sshd

- name: Enable SSH daemon
  systemd:
    name: sshd.service
    enabled: yes
    masked: no
    state: started
  when: not chroot
- name: '- when in chroot'
  command: systemctl enable sshd.service
  when: chroot

# vim: set ts=2 sw=2 et: