Compare commits
17
Commits
test_crypto_lib
...
8.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99fe8b6969 | ||
|
|
f8295d5248 | ||
|
|
a1f75f877b | ||
|
|
901923bac2 | ||
|
|
c30ef42355 | ||
|
|
e2b963d711 | ||
|
|
414efd6125 | ||
|
|
87a461fc57 | ||
|
|
dac66f4a88 | ||
|
|
3b8b394f10 | ||
|
|
b27ffd08b0 | ||
|
|
8ee946a537 | ||
|
|
a176443f22 | ||
|
|
9d75e3b00e | ||
|
|
a1b80fe657 | ||
|
|
53be805099 | ||
|
|
464d8df8e8 |
No files matched your search
@@ -11,6 +11,7 @@ exclude_paths:
|
||||
|
||||
skip_list:
|
||||
- fqcn-builtins
|
||||
- name[template]
|
||||
|
||||
mock_roles:
|
||||
- geerlingguy.git
|
||||
|
||||
@@ -26,7 +26,10 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centosstream8
|
||||
- centosstream9
|
||||
- rocky8
|
||||
- rocky9
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
- ubuntu2204
|
||||
|
||||
@@ -25,7 +25,10 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centosstream8
|
||||
- centosstream9
|
||||
- rocky8
|
||||
- rocky9
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
- ubuntu2204
|
||||
|
||||
@@ -25,7 +25,10 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centosstream8
|
||||
- centosstream9
|
||||
- rocky8
|
||||
- rocky9
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
- ubuntu2204
|
||||
|
||||
@@ -25,14 +25,17 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centos8s
|
||||
# - centos9s # problems with vagrant
|
||||
- rocky8
|
||||
# - rocky9 # problems with vagrant
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
- ubuntu2204
|
||||
- debian10
|
||||
- debian11
|
||||
# - opensuse42 # opensuse currently cannot get an ip address
|
||||
# - arch - arch is currently not supported by cinc-auditor
|
||||
# - arch # arch is currently not supported by cinc-auditor
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@@ -25,7 +25,10 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centosstream8
|
||||
- centosstream9
|
||||
- rocky8
|
||||
- rocky9
|
||||
- fedora
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
|
||||
@@ -25,7 +25,10 @@ jobs:
|
||||
matrix:
|
||||
molecule_distro:
|
||||
- centos7
|
||||
- centosstream8
|
||||
- centosstream9
|
||||
- rocky8
|
||||
- rocky9
|
||||
- fedora
|
||||
- ubuntu1804
|
||||
- ubuntu2004
|
||||
|
||||
+8
-2
@@ -1,8 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [8.2.1](https://github.com/dev-sec/ansible-collection-hardening/tree/8.2.1) (2022-10-20)
|
||||
## [8.3.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.3.0) (2022-10-26)
|
||||
|
||||
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/8.2.0...8.2.1)
|
||||
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/8.2.0...8.3.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- add hardening of root user account\(s\) [\#579](https://github.com/dev-sec/ansible-collection-hardening/pull/579) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([donestefan](https://github.com/donestefan))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
@@ -16,6 +20,8 @@
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- adopt all current suggestions from ansible-lint [\#592](https://github.com/dev-sec/ansible-collection-hardening/pull/592) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([schurzi](https://github.com/schurzi))
|
||||
- Support more os [\#588](https://github.com/dev-sec/ansible-collection-hardening/pull/588) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||
- run tests only on pushes to master or to PRs [\#581](https://github.com/dev-sec/ansible-collection-hardening/pull/581) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] [[nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/nginx_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
|
||||
|
||||
## [8.2.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.2.0) (2022-09-08)
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
- name: Run the equivalent of "apt-get update && apt-get upgrade"
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
|
||||
@@ -59,12 +59,14 @@
|
||||
- mysql_version.version.full is version('8.0.3', '>=')
|
||||
- mysql_distribution == "mysql"
|
||||
|
||||
- include: configure.yml
|
||||
- name: Include tasks for configuration
|
||||
import_tasks: configure.yml
|
||||
when: mysql_hardening_enabled | bool
|
||||
tags:
|
||||
- mysql_hardening
|
||||
|
||||
- include: mysql_secure_installation.yml
|
||||
- name: Include tasks to secure mysql installation
|
||||
import_tasks: mysql_secure_installation.yml
|
||||
when: mysql_hardening_enabled | bool
|
||||
tags:
|
||||
- mysql_hardening
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
msg: 'ERROR - you have to change default mysql_root_password'
|
||||
when: mysql_root_password == '-----====>SetR00tPa$$wordH3r3!!!<====-----'
|
||||
|
||||
- name: ensure that the root password is present
|
||||
- name: Ensure that the root password is present
|
||||
community.mysql.mysql_user:
|
||||
name: 'root'
|
||||
host_all: true
|
||||
@@ -19,14 +19,14 @@
|
||||
mode: '0400'
|
||||
tags: my_cnf
|
||||
|
||||
- name: ensure that the test database is absent
|
||||
- name: Ensure that the test database is absent
|
||||
community.mysql.mysql_db:
|
||||
name: test
|
||||
state: absent
|
||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||
when: mysql_remove_test_database
|
||||
|
||||
- name: ensure that anonymous users are absent
|
||||
- name: Ensure that anonymous users are absent
|
||||
community.mysql.mysql_user:
|
||||
name: ''
|
||||
state: absent
|
||||
@@ -34,7 +34,7 @@
|
||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||
when: mysql_remove_anonymous_users
|
||||
|
||||
- name: ensure that root can only login from localhost
|
||||
- name: Ensure that root can only login from localhost
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- DELETE
|
||||
@@ -46,7 +46,7 @@
|
||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||
when: mysql_remove_remote_root
|
||||
|
||||
- name: get all users that have no authentication_string on MySQL version >= 5.7.6 or Mariadb version >= 10.4.0
|
||||
- name: Get all users that have no authentication_string on MySQL version >= 5.7.6 or Mariadb version >= 10.4.0
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- SELECT GROUP_CONCAT(QUOTE(USER), '@', QUOTE(HOST) SEPARATOR ', ') AS users
|
||||
@@ -62,7 +62,7 @@
|
||||
- (mysql_distribution == "mysql" and mysql_version.version.full is version('5.7.6', '>=')) or
|
||||
(mysql_distribution == "mariadb" and mysql_version.version.full is version('10.4.0', '>='))
|
||||
|
||||
- name: get all users that have no password or authentication_string on MySQL version < 5.7.6 or Mariadb version < 10.4.0
|
||||
- name: Get all users that have no password or authentication_string on MySQL version < 5.7.6 or Mariadb version < 10.4.0
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- SELECT GROUP_CONCAT(QUOTE(USER), '@', QUOTE(HOST) SEPARATOR ', ') AS users
|
||||
@@ -80,21 +80,21 @@
|
||||
- (mysql_distribution == "mysql" and mysql_version.version.full is version('5.7.6', '<')) or
|
||||
(mysql_distribution == "mariadb" and mysql_version.version.full is version('10.4.0', '<'))
|
||||
|
||||
- name: create a fact for users without password or authentication_string
|
||||
- name: Create a fact for users without password or authentication_string
|
||||
set_fact:
|
||||
users_wo_auth: "{{ mysql_users_wo_passwords_or_auth_string.query_result.0.0 | community.general.json_query('users') }}"
|
||||
when:
|
||||
- mysql_users_wo_passwords_or_auth_string.query_result is defined
|
||||
- mysql_users_wo_passwords_or_auth_string.query_result != "" # noqa empty-string-compare
|
||||
|
||||
- name: create a fact for users without password
|
||||
- name: Create a fact for users without password
|
||||
set_fact:
|
||||
users_wo_auth: "{{ mysql_users_wo_passwords.query_result.0.0 | community.general.json_query('users') }}"
|
||||
when:
|
||||
- mysql_users_wo_passwords.query_result is defined
|
||||
- mysql_users_wo_passwords.query_result != "" # noqa empty-string-compare
|
||||
|
||||
- name: ensure that there are no users without password or authentication_string
|
||||
- name: Ensure that there are no users without password or authentication_string
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- "DROP USER {{ users_wo_auth }}"
|
||||
|
||||
File renamed without changes.
@@ -1,9 +0,0 @@
|
||||
---
|
||||
mysql_daemon: mariadb
|
||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||
|
||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||
|
||||
mysql_hardening_group: 'mysql'
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
mysql_daemon: mariadb
|
||||
mysql_hardening_mysql_conf_file: '/etc/my.cnf'
|
||||
mysql_hardening_mysql_confd_dir: '/etc/my.cnf.d'
|
||||
|
||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||
|
||||
mysql_hardening_group: 'mysql'
|
||||
File renamed without changes.
@@ -1,10 +0,0 @@
|
||||
---
|
||||
mysql_daemon: mysql
|
||||
|
||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||
|
||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||
|
||||
mysql_hardening_group: 'adm'
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
mysql_daemon: mysql
|
||||
|
||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||
|
||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||
|
||||
mysql_hardening_group: 'adm'
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
mysql_daemon: mysql
|
||||
|
||||
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
|
||||
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
|
||||
|
||||
mysql_cnf_owner: 'root' # owner of /etc/mysql/*.cnf files
|
||||
mysql_cnf_group: 'mysql' # owner of /etc/mysql/*.cnf files
|
||||
|
||||
mysql_hardening_group: 'adm'
|
||||
@@ -230,6 +230,15 @@ We know that this is the case on Raspberry Pi.
|
||||
- `os_ignore_home_folder_users`
|
||||
- Default: `lost+found`
|
||||
- Description: specify user home folders in `/home` that shouldn't be chmodded to 700
|
||||
- `os_chmod_rootuser_home_folder`
|
||||
- Default: `true`
|
||||
- Description: Set to `false` to disable "chmod 700" of root's home folder
|
||||
- `os_rootuser_pw_ageing`
|
||||
- Default: `false`
|
||||
- Description: Set to true to enforce password age settings for root user(s)
|
||||
- `os_remove_additional_root_users`
|
||||
- Default: `false`
|
||||
- Description: When enabled and there are multiple users with UID=0, only "root" will be kept. Others will be deleted.
|
||||
- `os_cron_enabled`
|
||||
- Default: `true`
|
||||
- Description: Set to false to disable installing and configuring cron.
|
||||
@@ -241,7 +250,7 @@ We know that this is the case on Raspberry Pi.
|
||||
- Description: Set to false to disable installing and configuring limits.
|
||||
- `os_login_defs_enabled`
|
||||
- Default: `true`
|
||||
- Description: Set to false to disable installing and configuring login_defs.
|
||||
- Description: Set to false to disable installing and configuring login_defs for newly created users.
|
||||
- `os_minimize_access_enabled`
|
||||
- Default: `true`
|
||||
- Description: Set to false to disable installing and configuring minimize_access.
|
||||
|
||||
@@ -15,13 +15,21 @@ os_auth_root_ttys: [console, tty1, tty2, tty3, tty4, tty5, tty6]
|
||||
|
||||
os_chfn_restrict: ''
|
||||
|
||||
# Set to false to disable chmod /home folders to 700
|
||||
# Set to false to disable chmod userhome folders to 700
|
||||
os_chmod_rootuser_home_folder: true
|
||||
os_chmod_home_folders: true
|
||||
|
||||
# May contain: change_user
|
||||
os_security_users_allow: []
|
||||
# Specify user home folders in /home that shouldn't be chmodded to 700
|
||||
os_ignore_home_folder_users: ['lost+found']
|
||||
|
||||
# Set to false to disable password age enforcement on existing users
|
||||
os_rootuser_pw_ageing: false
|
||||
|
||||
# When enabled and there are multiple users with UID=0, only "root" will be kept. Others will be deleted.
|
||||
os_remove_additional_root_users: false
|
||||
|
||||
# Specify system accounts whose login should not be disabled and password not changed
|
||||
os_ignore_users: ['vagrant', 'kitchen']
|
||||
os_security_kernel_enable_module_loading: true
|
||||
@@ -338,7 +346,7 @@ os_ctrlaltdel_disabled: false
|
||||
# Set to false to disable installing and configuring limits.
|
||||
os_limits_enabled: true
|
||||
|
||||
# Set to false to disable installing and configuring login_defs.
|
||||
# Set to false to disable installing and configuring login_defs for newly created users.
|
||||
os_login_defs_enabled: true
|
||||
|
||||
# Set to false to disable installing and configuring minimize_access.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Update-initramfs
|
||||
command: 'update-initramfs -u'
|
||||
|
||||
- name: restart-auditd
|
||||
- name: Restart auditd
|
||||
command:
|
||||
cmd: 'service auditd restart' # rhel: see: https://access.redhat.com/solutions/2664811
|
||||
warn: false # sadly 'service' module fails in that case also by using 'use: service'
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0640'
|
||||
notify: 'restart-auditd'
|
||||
notify: Restart auditd
|
||||
tags: auditd
|
||||
@@ -22,79 +22,97 @@
|
||||
with_dict: '{{ os_vars }}'
|
||||
tags: always
|
||||
|
||||
- import_tasks: auditd.yml
|
||||
- name: Import tasks for auditd
|
||||
import_tasks: auditd.yml
|
||||
tags: auditd
|
||||
when: os_auditd_enabled | bool
|
||||
|
||||
- import_tasks: cron.yml
|
||||
- name: Import tasks for cron
|
||||
import_tasks: cron.yml
|
||||
tags: cron
|
||||
when: os_cron_enabled | bool
|
||||
|
||||
- import_tasks: ctrlaltdel.yml
|
||||
- name: Import tasks to configure ctrl+alt+del
|
||||
import_tasks: ctrlaltdel.yml
|
||||
tags: ctrlaltdel
|
||||
when: os_ctrlaltdel_disabled | bool
|
||||
|
||||
- import_tasks: limits.yml
|
||||
- name: Import tasks to configure limits
|
||||
import_tasks: limits.yml
|
||||
tags: limits
|
||||
when: os_limits_enabled | bool
|
||||
|
||||
- import_tasks: login_defs.yml
|
||||
- name: Import tasks to configure login_defs
|
||||
import_tasks: login_defs.yml
|
||||
tags: login_defs
|
||||
when: os_login_defs_enabled | bool
|
||||
|
||||
- import_tasks: minimize_access.yml
|
||||
- name: Import tasks to minimize access permissions
|
||||
import_tasks: minimize_access.yml
|
||||
tags: minimize_access
|
||||
when: os_minimize_access_enabled | bool
|
||||
|
||||
- import_tasks: pam.yml
|
||||
- name: Import tasks to configure PAM
|
||||
import_tasks: pam.yml
|
||||
tags: pam
|
||||
when: os_pam_enabled | bool
|
||||
|
||||
- import_tasks: modprobe.yml
|
||||
- name: Import tasks to configure modules
|
||||
import_tasks: modprobe.yml
|
||||
tags: modprobe
|
||||
when: os_modprobe_enabled | bool
|
||||
|
||||
- import_tasks: profile.yml
|
||||
- name: Import tasks to configure profile
|
||||
import_tasks: profile.yml
|
||||
tags: profile
|
||||
when: os_profile_enabled | bool
|
||||
|
||||
- import_tasks: securetty.yml
|
||||
- name: Import tasks to configure securetty
|
||||
import_tasks: securetty.yml
|
||||
tags: securetty
|
||||
when: os_securetty_enabled | bool
|
||||
|
||||
- import_tasks: suid_sgid.yml
|
||||
- name: Import tasks to set suid and sgid
|
||||
import_tasks: suid_sgid.yml
|
||||
when: os_security_suid_sgid_enforce | bool
|
||||
tags: suid_sgid
|
||||
|
||||
- import_tasks: sysctl.yml
|
||||
- name: Import tasks to configure sysctl
|
||||
import_tasks: sysctl.yml
|
||||
tags: sysctl
|
||||
when: os_sysctl_enabled | bool
|
||||
|
||||
- import_tasks: user_accounts.yml
|
||||
- name: Import tasks to harden user accounts
|
||||
import_tasks: user_accounts.yml
|
||||
tags: user_accounts
|
||||
when: os_user_accounts_enabled | bool
|
||||
|
||||
- import_tasks: rhosts.yml
|
||||
- name: Import tasks to configure rhosts
|
||||
import_tasks: rhosts.yml
|
||||
tags: rhosts
|
||||
when: os_rhosts_enabled | bool
|
||||
|
||||
- import_tasks: netrc.yml
|
||||
- name: Import tasks to configure netrc
|
||||
import_tasks: netrc.yml
|
||||
tags: netrc
|
||||
when: os_netrc_enabled | bool
|
||||
|
||||
- import_tasks: yum.yml
|
||||
- name: Import tasks to configure yum
|
||||
import_tasks: yum.yml
|
||||
tags: yum
|
||||
when:
|
||||
- ansible_facts.os_family == 'RedHat'
|
||||
- os_yum_enabled | bool
|
||||
|
||||
- import_tasks: apt.yml
|
||||
- name: Import tasks to configure apt
|
||||
import_tasks: apt.yml
|
||||
tags: apt
|
||||
when:
|
||||
- ansible_facts.os_family == 'Debian'
|
||||
- os_apt_enabled | bool
|
||||
|
||||
- import_tasks: selinux.yml
|
||||
- name: Import tasks to configure selinux
|
||||
import_tasks: selinux.yml
|
||||
tags: selinux
|
||||
when:
|
||||
- ansible_facts.selinux.status == 'enabled'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
- name: disable coredumps
|
||||
- name: Disable coredumps
|
||||
when: not os_security_kernel_enable_core_dump | bool
|
||||
block:
|
||||
- name: Create limits.d-directory if it does not exist | sysctl-31a, sysctl-31b
|
||||
file:
|
||||
@@ -28,7 +29,7 @@
|
||||
modification_time: preserve
|
||||
access_time: preserve
|
||||
|
||||
- name: create coredump.conf.d-directory if it does not exist
|
||||
- name: Create coredump.conf.d-directory if it does not exist
|
||||
file:
|
||||
path: '/etc/systemd/coredump.conf.d'
|
||||
owner: root
|
||||
@@ -37,7 +38,7 @@
|
||||
state: directory
|
||||
when: ansible_service_mgr == "systemd"
|
||||
|
||||
- name: create custom.conf for disabling coredumps
|
||||
- name: Create custom.conf for disabling coredumps
|
||||
template:
|
||||
src: 'etc/systemd/coredump.conf.d/coredumps.conf.j2'
|
||||
dest: '/etc/systemd/coredump.conf.d/custom.conf'
|
||||
@@ -47,9 +48,8 @@
|
||||
when: ansible_service_mgr == "systemd"
|
||||
notify: Reload systemd
|
||||
|
||||
when: not os_security_kernel_enable_core_dump | bool
|
||||
|
||||
- name: enable coredumps
|
||||
- name: Enable coredumps
|
||||
when: os_security_kernel_enable_core_dump | bool
|
||||
block:
|
||||
- name: Remove coredump.conf.d directory with files
|
||||
file:
|
||||
@@ -62,4 +62,3 @@
|
||||
file:
|
||||
path: /etc/security/limits.d/10.hardcore.conf
|
||||
state: absent
|
||||
when: os_security_kernel_enable_core_dump | bool
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
- include_tasks: hardening.yml
|
||||
- name: Include hardening tasks
|
||||
include_tasks: hardening.yml
|
||||
when: os_hardening_enabled | bool
|
||||
tags:
|
||||
- always
|
||||
@@ -17,11 +17,13 @@
|
||||
when:
|
||||
- ansible_facts.os_family != 'Archlinux'
|
||||
|
||||
- import_tasks: pam_debian.yml
|
||||
- name: Import tasks for Debian PAM
|
||||
import_tasks: pam_debian.yml
|
||||
when:
|
||||
- ansible_facts.os_family == 'Debian'
|
||||
|
||||
- import_tasks: pam_rhel.yml
|
||||
- name: Import tasks for RedHat PAM
|
||||
import_tasks: pam_rhel.yml
|
||||
when:
|
||||
- ansible_facts.os_family == 'RedHat'
|
||||
|
||||
|
||||
@@ -22,9 +22,12 @@
|
||||
name: 'libpam-modules'
|
||||
state: 'present'
|
||||
when:
|
||||
- os_auth_retries > 0
|
||||
- os_auth_retries|int > 0
|
||||
|
||||
- name: Manage tally on Debian stable
|
||||
when:
|
||||
- "'libpam-modules' in ansible_facts.packages"
|
||||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '<')"
|
||||
block:
|
||||
- name: Configure tally2
|
||||
template:
|
||||
@@ -34,26 +37,26 @@
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
when:
|
||||
- os_auth_retries > 0
|
||||
- os_auth_retries|int > 0
|
||||
|
||||
- name: Delete tally2 when retries is 0
|
||||
file:
|
||||
path: '{{ tally2_path }}'
|
||||
state: 'absent'
|
||||
when:
|
||||
- os_auth_retries == 0
|
||||
when:
|
||||
- "'libpam-modules' in ansible_facts.packages"
|
||||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '<')"
|
||||
- os_auth_retries|int == 0
|
||||
|
||||
- name: Manage tally/faillock on Debian unstable
|
||||
when:
|
||||
- "'libpam-modules' in ansible_facts.packages"
|
||||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '>=')"
|
||||
block:
|
||||
- name: Delete tally2
|
||||
file:
|
||||
path: '{{ tally2_path }}'
|
||||
state: 'absent'
|
||||
|
||||
- name: create tally directory
|
||||
- name: Create tally directory
|
||||
file:
|
||||
path: '/var/run/faillock'
|
||||
state: 'directory'
|
||||
@@ -77,7 +80,7 @@
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
when:
|
||||
- os_auth_retries > 0
|
||||
- os_auth_retries|int > 0
|
||||
|
||||
- name: Configure faillock pam authfail
|
||||
template:
|
||||
@@ -87,24 +90,21 @@
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
when:
|
||||
- os_auth_retries > 0
|
||||
- os_auth_retries|int > 0
|
||||
|
||||
- name: Delete faillock when retries is 0
|
||||
file:
|
||||
path: '/usr/share/pam-configs/faillock'
|
||||
state: 'absent'
|
||||
when:
|
||||
- os_auth_retries == 0
|
||||
- os_auth_retries|int == 0
|
||||
|
||||
- name: Delete faillock authfail when retries is 0
|
||||
file:
|
||||
path: '/usr/share/pam-configs/faillock_authfail'
|
||||
state: 'absent'
|
||||
when:
|
||||
- os_auth_retries == 0
|
||||
when:
|
||||
- "'libpam-modules' in ansible_facts.packages"
|
||||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '>=')"
|
||||
- os_auth_retries|int == 0
|
||||
|
||||
- name: Update pam on Debian systems
|
||||
command: 'pam-auth-update --package'
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
register: initramfs
|
||||
|
||||
- name: Change sysctls
|
||||
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
|
||||
block:
|
||||
- name: Create a combined sysctl-dict if os-dependent sysctls are defined
|
||||
set_fact:
|
||||
@@ -69,7 +70,6 @@
|
||||
ignoreerrors: true
|
||||
with_dict: '{{ sysctl_config }}'
|
||||
when: item.key not in sysctl_unsupported_entries | default()
|
||||
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
|
||||
|
||||
- name: Apply ufw defaults
|
||||
template:
|
||||
|
||||
@@ -1,4 +1,45 @@
|
||||
---
|
||||
- name: Read local linux user database
|
||||
getent:
|
||||
database: passwd
|
||||
# creates a dict for each user containing UID/HOMEDIR etc...
|
||||
when: getent_passwd is undefined # skip this task if "getent" has run before
|
||||
|
||||
- name: Extract root account(s) from local user database
|
||||
loop: "{{ getent_passwd.keys() | list }}"
|
||||
when:
|
||||
- getent_passwd[item][1]|int == 0
|
||||
set_fact:
|
||||
root_users: "{{ root_users | default([]) + [item] }}"
|
||||
|
||||
- name: Set ownership of root user home directory(s) to 0700
|
||||
file:
|
||||
mode: 0700
|
||||
owner: "{{ item }}"
|
||||
path: "{{ getent_passwd[item][4] }}"
|
||||
state: directory
|
||||
loop: "{{ root_users }}"
|
||||
when:
|
||||
- os_chmod_rootuser_home_folder | bool
|
||||
|
||||
- name: Set password ageing for root user(s)
|
||||
user:
|
||||
name: "{{ item }}"
|
||||
password_expire_min: "{{ os_auth_pw_min_age }}"
|
||||
password_expire_max: "{{ os_auth_pw_max_age }}"
|
||||
loop: "{{ root_users }}"
|
||||
when: os_rootuser_pw_ageing|bool
|
||||
|
||||
- name: Remove additional users with UID=0 ("root" user is not touched)
|
||||
user:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ root_users }}"
|
||||
when:
|
||||
- os_remove_additional_root_users|bool
|
||||
- root_users|length > 1
|
||||
- item != "root"
|
||||
|
||||
- name: Get UID_MIN from login.defs
|
||||
shell: awk '/^\s*UID_MIN\s*([0-9]*).*?$/ {print $2}' /etc/login.defs
|
||||
args:
|
||||
@@ -25,7 +66,7 @@
|
||||
when: uid_max is not defined
|
||||
|
||||
- name: Get all system accounts
|
||||
command: awk -F'':'' '{ if ( $3 <= {{ uid_max|quote }} ) print $1}' /etc/passwd
|
||||
command: awk -F'':'' '{ if ( $3 <= {{ uid_max | quote }} ) print $1}' /etc/passwd
|
||||
args:
|
||||
removes: /etc/passwd
|
||||
changed_when: false
|
||||
@@ -46,7 +87,7 @@
|
||||
with_community.general.flattened:
|
||||
- '{{ sys_accs_cond | default([]) | difference(os_ignore_users) | list }}'
|
||||
|
||||
- name: get all home directories in /home, but skip ignored users
|
||||
- name: Get all home directories in /home, but skip ignored users
|
||||
find:
|
||||
paths: /home/
|
||||
recurse: false
|
||||
@@ -55,7 +96,7 @@
|
||||
register: home_directories
|
||||
when: os_chmod_home_folders | bool
|
||||
|
||||
- name: set ownership of /home directories to 0700
|
||||
- name: Set ownership of /home directories to 0700
|
||||
file:
|
||||
mode: 0700
|
||||
path: "{{ item.path }}"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#%PAM-1.0
|
||||
auth required pam_env.so
|
||||
auth required pam_faildelay.so delay=2000000
|
||||
{% if os_auth_retries > 0 %}
|
||||
{% if os_auth_retries|int > 0 %}
|
||||
auth required pam_faillock.so preauth silent audit even_deny_root deny={{ os_auth_retries }} unlock_time={{ os_auth_lockout_time }}
|
||||
{% endif %}
|
||||
{% if (os_auth_pam_sssd_enable | bool) %}
|
||||
@@ -16,12 +16,12 @@ auth sufficient pam_unix.so nullok try_first_pass
|
||||
auth [default=1 ignore=ignore success=ok] pam_succeed_if.so uid >= 1000 quiet
|
||||
auth sufficient pam_sss.so forward_pass
|
||||
{% endif %}
|
||||
{% if os_auth_retries > 0 %}
|
||||
{% if os_auth_retries|int > 0 %}
|
||||
auth required pam_faillock.so authfail audit even_deny_root deny={{ os_auth_retries }} unlock_time={{ os_auth_lockout_time }}
|
||||
{% endif %}
|
||||
auth required pam_deny.so
|
||||
|
||||
{% if os_auth_retries > 0 %}
|
||||
{% if os_auth_retries|int > 0 %}
|
||||
account required pam_faillock.so
|
||||
{% endif %}
|
||||
account required pam_unix.so
|
||||
|
||||
@@ -33,7 +33,7 @@ os_auth_sub_gid_min: 100000
|
||||
os_auth_sub_gid_max: 600100000
|
||||
os_auth_sub_gid_count: 65536
|
||||
|
||||
os_auth_pam_sssd_enable: false
|
||||
os_auth_pam_sssd_enable: true
|
||||
|
||||
# defaults for useradd
|
||||
os_useradd_mail_dir: /var/spool/mail
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
|
||||
os_packages_pam_ccreds: 'pam_ccreds'
|
||||
os_nologin_shell_path: '/sbin/nologin'
|
||||
|
||||
# Different distros use different standards for /etc/shadow perms, e.g.
|
||||
# RHEL derivatives use root:root 0000, whereas Debian-based use root:shadow 0640.
|
||||
# You must provide key/value pairs for owner, group, and mode if overriding.
|
||||
os_shadow_perms:
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0000'
|
||||
|
||||
os_passwd_perms:
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
os_env_umask: '077'
|
||||
|
||||
os_auth_uid_min: 1000
|
||||
os_auth_uid_max: 60000
|
||||
os_auth_gid_min: 1000
|
||||
os_auth_gid_max: 60000
|
||||
os_auth_sys_uid_min: 201
|
||||
os_auth_sys_uid_max: 999
|
||||
os_auth_sys_gid_min: 201
|
||||
os_auth_sys_gid_max: 999
|
||||
os_auth_sub_uid_min: 100000
|
||||
os_auth_sub_uid_max: 600100000
|
||||
os_auth_sub_uid_count: 65536
|
||||
os_auth_sub_gid_min: 100000
|
||||
os_auth_sub_gid_max: 600100000
|
||||
os_auth_sub_gid_count: 65536
|
||||
|
||||
os_auth_pam_sssd_enable: true
|
||||
|
||||
# defaults for useradd
|
||||
os_useradd_mail_dir: /var/spool/mail
|
||||
os_useradd_create_home: true
|
||||
|
||||
modprobe_package: 'module-init-tools'
|
||||
auditd_package: 'audit'
|
||||
|
||||
hidepid_option: '2' # allowed values: 0, 1, 2
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
|
||||
os_packages_pam_ccreds: 'pam_ccreds'
|
||||
os_nologin_shell_path: '/sbin/nologin'
|
||||
|
||||
# Different distros use different standards for /etc/shadow perms, e.g.
|
||||
# RHEL derivatives use root:root 0000, whereas Debian-based use root:shadow 0640.
|
||||
# You must provide key/value pairs for owner, group, and mode if overriding.
|
||||
os_shadow_perms:
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0000'
|
||||
|
||||
os_passwd_perms:
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
os_env_umask: '077'
|
||||
|
||||
os_auth_uid_min: 1000
|
||||
os_auth_uid_max: 60000
|
||||
os_auth_gid_min: 1000
|
||||
os_auth_gid_max: 60000
|
||||
os_auth_sys_uid_min: 201
|
||||
os_auth_sys_uid_max: 999
|
||||
os_auth_sys_gid_min: 201
|
||||
os_auth_sys_gid_max: 999
|
||||
os_auth_sub_uid_min: 100000
|
||||
os_auth_sub_uid_max: 600100000
|
||||
os_auth_sub_uid_count: 65536
|
||||
os_auth_sub_gid_min: 100000
|
||||
os_auth_sub_gid_max: 600100000
|
||||
os_auth_sub_gid_count: 65536
|
||||
|
||||
os_auth_pam_sssd_enable: true
|
||||
|
||||
# defaults for useradd
|
||||
os_useradd_mail_dir: /var/spool/mail
|
||||
os_useradd_create_home: true
|
||||
|
||||
modprobe_package: 'module-init-tools'
|
||||
auditd_package: 'audit'
|
||||
|
||||
hidepid_option: '2' # allowed values: 0, 1, 2
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
- include_tasks: hardening.yml
|
||||
- name: Include hardening tasks
|
||||
include_tasks: hardening.yml
|
||||
args:
|
||||
apply:
|
||||
become: true
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
# The following tasks only get executed when selinux is in state enforcing,
|
||||
# UsePam is 'no' and the ssh_password module is not installed. See this issue for
|
||||
# more info: https://github.com/hardening-io/ansible-ssh-hardening/issues/23
|
||||
- name: run selinux tasks
|
||||
- name: Run selinux tasks
|
||||
when:
|
||||
- not (ssh_use_pam | bool)
|
||||
- ('ssh_password' not in ssh_password_module.stdout)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
sshd_path: /usr/sbin/sshd
|
||||
ssh_host_keys_dir: '/etc/ssh'
|
||||
sshd_service_name: sshd
|
||||
ssh_owner: root
|
||||
ssh_group: root
|
||||
ssh_host_keys_owner: 'root'
|
||||
ssh_host_keys_group: 'ssh_keys'
|
||||
ssh_selinux_packages:
|
||||
- policycoreutils-python-utils
|
||||
- checkpolicy
|
||||
|
||||
# true if SSH support Kerberos
|
||||
ssh_kerberos_support: true
|
||||
|
||||
# true if SSH has PAM support
|
||||
ssh_pam_support: true
|
||||
|
||||
sshd_moduli_file: '/etc/ssh/moduli'
|
||||
|
||||
# disable CRYPTO_POLICY to take settings from sshd configuration
|
||||
# see: https://access.redhat.com/solutions/4410591
|
||||
sshd_disable_crypto_policy: true
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
sshd_path: /usr/sbin/sshd
|
||||
ssh_host_keys_dir: '/etc/ssh'
|
||||
sshd_service_name: sshd
|
||||
ssh_owner: root
|
||||
ssh_group: root
|
||||
ssh_host_keys_owner: 'root'
|
||||
ssh_host_keys_group: 'ssh_keys'
|
||||
ssh_selinux_packages:
|
||||
- policycoreutils-python-utils
|
||||
- checkpolicy
|
||||
|
||||
# true if SSH support Kerberos
|
||||
ssh_kerberos_support: true
|
||||
|
||||
# true if SSH has PAM support
|
||||
ssh_pam_support: true
|
||||
|
||||
sshd_moduli_file: '/etc/ssh/moduli'
|
||||
|
||||
# disable CRYPTO_POLICY to take settings from sshd configuration
|
||||
# see: https://access.redhat.com/solutions/4410591
|
||||
sshd_disable_crypto_policy: true
|
||||
@@ -7,7 +7,7 @@ ssh_group: root
|
||||
ssh_host_keys_owner: 'root'
|
||||
ssh_host_keys_group: 'ssh_keys'
|
||||
ssh_selinux_packages:
|
||||
- policycoreutils-python
|
||||
- policycoreutils-python-utils
|
||||
- checkpolicy
|
||||
|
||||
# true if SSH support Kerberos
|
||||
|
||||
@@ -7,7 +7,7 @@ ssh_group: root
|
||||
ssh_host_keys_owner: 'root'
|
||||
ssh_host_keys_group: 'ssh_keys'
|
||||
ssh_selinux_packages:
|
||||
- python3-policycoreutils
|
||||
- policycoreutils-python
|
||||
- checkpolicy
|
||||
|
||||
# true if SSH support Kerberos
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
sshd_path: /usr/sbin/sshd
|
||||
ssh_host_keys_dir: '/etc/ssh'
|
||||
sshd_service_name: sshd
|
||||
ssh_owner: root
|
||||
ssh_group: root
|
||||
ssh_host_keys_owner: 'root'
|
||||
ssh_host_keys_group: 'ssh_keys'
|
||||
ssh_selinux_packages:
|
||||
- python3-policycoreutils
|
||||
- checkpolicy
|
||||
|
||||
# true if SSH support Kerberos
|
||||
ssh_kerberos_support: true
|
||||
|
||||
# true if SSH has PAM support
|
||||
ssh_pam_support: true
|
||||
|
||||
sshd_moduli_file: '/etc/ssh/moduli'
|
||||
|
||||
# disable CRYPTO_POLICY to take settings from sshd configuration
|
||||
# see: https://access.redhat.com/solutions/4410591
|
||||
sshd_disable_crypto_policy: true
|
||||
Reference in new issue
Block a user