-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity.yml
70 lines (60 loc) · 1.98 KB
/
security.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
- hosts: all
tasks:
- name: firewall
become: true
tags: firewall
block:
- name: iptables base setup
script: firewall.sh
- apt:
pkg: netfilter-persistent
state: latest
update_cache: yes
- name: netfilter-persistent
command: /usr/sbin/netfilter-persistent save
- name: sshd_config
become: true
tags: ssh sshd
block:
- name: "sshd_config {{ item.k }}"
replace: &sshd_config_replace
path: /etc/ssh/sshd_config
backup: yes
regexp: '(?i)^[\s#]*{{item.k}}.*$'
replace: "{{item.k}} {{item.v}}"
with_items:
# no ipv6
- { k: AddressFamily, v: inet }
- { k: 'ListenAddress\s+::,', v: '' }
# logs
- { k: LogLevel, v: VERBOSE }
# auth
- { k: 'PermitRootLogin:', v: no }
- { k: LoginGraceTime, v: 15 }
- { k: MaxAuthTries, v: 3 }
- { k: AuthenticationMethods, v: publickey }
- k: KexAlgorithms
v: "curve25519-sha256@libssh.org,\
ecdh-sha2-nistp521,\
ecdh-sha2-nistp384,\
ecdh-sha2-nistp256"
# diffie-hellman-group-exchange-sha256
- k: Ciphers
v: "chacha20-poly1305@openssh.com,\
aes256-gcm@openssh.com,\
aes128-gcm@openssh.com"
- k: MACs
v: "hmac-sha2-512-etm@openssh.com,\
hmac-sha2-512"
# - { k: UsePrivilegeSeparation, v: sandbox }
# XXX: should probably be `ansible_ssh_user` for a production use
# - { k: AllowUsers, v: "{{ users.admin }}@127.0.0.1"
- name: "sshd_config sftp"
replace:
<<: *sshd_config_replace
regexp: '(?i)^[\s#]*SUBSYSTEM\s+SFTP\s+([-\w/]+)\s*$'
replace: 'Subsystem sftp \1 -f AUTHPRIV -l INFO'
- service:
name: ssh
state: restarted