Compare commits

..
Author SHA1 Message Date
dev-sec CI c0b9c87dc1 update changelog 2023-01-19 12:47:40 +00:00
Sebastian Gumprich 142782bad6 add diff to molecule
Signed-off-by: Sebastian Gumprich <[email protected]>
2023-01-19 13:46:16 +01:00
rndmh3ro b3fbfcedbe Prettified Code! 2023-01-19 12:45:51 +00:00
88ef3cf3af Parametrize more auditd.conf options (#535)
* Parametrize more auditd.conf options

* Parametrize more auditd.conf options

* Add `os_auditd` options

* Add os_auditd_log_group

* Add os_auditd_log_group

Co-authored-by: Paweł Krawczyk <[email protected]>
Co-authored-by: Sebastian Gumprich <[email protected]>
2023-01-19 13:45:24 +01:00
dev-sec CI ca25f50ba6 update changelog 2023-01-12 11:56:07 +00:00
richardlock a82942a63a Add support for /etc/auditd.conf num_logs to go with max_log_file_action. (#617)
Signed-off-by: Richard Lock <[email protected]>

Signed-off-by: Richard Lock <[email protected]>
2023-01-12 12:52:48 +01:00
dev-sec CI fc060376ac update changelog 2022-12-24 09:43:18 +00:00
dependabot[bot] 16f78bc6be Bump actions/setup-python from 1 to 4 (#611)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 1 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v1...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-24 10:28:54 +01:00
dev-sec CI 764472ae33 update galaxy.yml with new version 2022-12-19 08:43:22 +00:00
dependabot[bot] 395091c41d Bump creyD/prettier_action from 3.1 to 4.2 (#610)
Bumps [creyD/prettier_action](https://github.com/creyD/prettier_action) from 3.1 to 4.2.
- [Release notes](https://github.com/creyD/prettier_action/releases)
- [Commits](https://github.com/creyD/prettier_action/compare/v3.1...v4.2)

---
updated-dependencies:
- dependency-name: creyD/prettier_action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-17 19:53:05 +01:00
dev-sec CI 0a589e5f51 update changelog 2022-12-17 18:49:42 +00:00
John Losito 9d0cc42039 Check for github action updates daily (#609)
Signed-off-by: John Losito <[email protected]>

Signed-off-by: John Losito <[email protected]>
2022-12-17 19:48:02 +01:00
dev-sec CI 5a7783defe update changelog 2022-12-07 07:55:29 +00:00
Sebastian Gumprichandschurzi be0642bcfb add verify-task to check if mysql is running and enabled (#608)
* add verify-task to check if mysql is running and enabled

Signed-off-by: Sebastian Gumprich <[email protected]>

* Update molecule/mysql_hardening/verify_tasks/service.yml

Co-authored-by: schurzi <[email protected]>

Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: schurzi <[email protected]>
2022-12-07 08:49:07 +01:00
dev-sec CI b0454fade2 update changelog 2022-11-30 15:15:52 +00:00
DonEstefananddonestefan bb3c63e321 fix IPv6 hardening (#607)
Signed-off-by: DonEstefan <[email protected]>

Signed-off-by: DonEstefan <[email protected]>
Co-authored-by: donestefan <[email protected]>
2022-11-30 16:13:25 +01:00
dev-sec CI d3e6df3dbf update changelog 2022-11-29 14:11:39 +00:00
Sebastian GumprichandFlorian Goth e66c2eb6bb Add OpenSUSE support (#605)
* Add variables for mariadb on opensuse

Signed-off-by: Florian Goth <[email protected]>

* enable pipeline

Signed-off-by: Florian Goth <[email protected]>

* add a note about the reuirement of the jmespath library.

Signed-off-by: Florian Goth <[email protected]>

* Use python3 on opensuse

Signed-off-by: Florian Goth <[email protected]>

* fix my yml.

Signed-off-by: Florian Goth <[email protected]>

* use right ansible variable

Signed-off-by: Florian Goth <[email protected]>

* Suse requires python-rpm

Signed-off-by: Florian Goth <[email protected]>

* try zypper

Signed-off-by: Florian Goth <[email protected]>

* python-xml

Signed-off-by: Florian Goth <[email protected]>

* another try at fixing the install

Signed-off-by: Florian Goth <[email protected]>

* fix my yml

Signed-off-by: Florian Goth <[email protected]>

* another try

Signed-off-by: Florian Goth <[email protected]>

* another try

Signed-off-by: Florian Goth <[email protected]>

* another try now with rpm.

Signed-off-by: Florian Goth <[email protected]>

* fix my yml...

Signed-off-by: Florian Goth <[email protected]>

* typo

Signed-off-by: Florian Goth <[email protected]>

* do the test for Suse on the shell and not in ansible

Signed-off-by: Florian Goth <[email protected]>

* specify to use bash

Signed-off-by: Florian Goth <[email protected]>

* specify to use bash

* try the removes keyword of builtin.shell

Signed-off-by: Florian Goth <[email protected]>

* fix ansible syntax

Signed-off-by: Florian Goth <[email protected]>

* fix zypper syntax

Signed-off-by: Florian Goth <[email protected]>

* ensure pymysql is present

Signed-off-by: Florian Goth <[email protected]>

* set ansible python interpreter in converge-step, too

Signed-off-by: Sebastian Gumprich <[email protected]>

* move install task to prepare

Signed-off-by: Sebastian Gumprich <[email protected]>

Signed-off-by: Florian Goth <[email protected]>
Signed-off-by: Sebastian Gumprich <[email protected]>
Co-authored-by: Florian Goth <[email protected]>
2022-11-29 15:09:27 +01:00
dev-sec CI 61e92aaaf6 update changelog 2022-11-24 07:41:20 +00:00
Jacob Sievert ade6deeba2 Updates handlers for new ansible syntax and deprecated options for legacy commands (#602)
* Update main.yml

fixes the handler file and set new syntax

Signed-off-by: Jacob Sievert <[email protected]>

* changes command module from legacy to builtin.

Signed-off-by: Jacob Sievert <[email protected]>

Signed-off-by: Jacob Sievert <[email protected]>
2022-11-24 08:39:05 +01:00
dev-sec CI 66f5c6b131 update changelog 2022-11-23 12:51:31 +00:00
Cristian Baldi 7d1da63c94 Allow ssh_allow_tcp_forwarding to be a boolean (#600)
* Allow ssh_allow_tcp_forwarding to be a boolean

Signed-off-by: Cristian Baldi <[email protected]>

* Update documentation related to ssh_allow_tcp_forwarding

Signed-off-by: Cristian Baldi <[email protected]>

Signed-off-by: Cristian Baldi <[email protected]>
2022-11-23 13:45:01 +01:00
dev-sec CI 03f3974f37 update changelog 2022-11-17 13:01:02 +00:00
schurzi 006e3bf75b Merge pull request #601 from dev-sec/contribute_dco
add notice to sign-off work to contributor guideline
2022-11-17 13:58:08 +01:00
Martin Schurz 98c645db5f add notice to sign-off work to contributor guideline
Signed-off-by: Martin Schurz <[email protected]>
2022-11-17 13:47:11 +01:00
dev-sec CI dd97a90b65 update changelog 2022-11-08 09:29:35 +00:00
schurzi d982a89cc1 Merge pull request #598 from dennisse/master
OpenBSD does not support GSSAPI Authentication
2022-11-08 10:26:42 +01:00
Dennis Eriksen 681898bd96 OpenBSD does not support GSSAPIAuthentication
... and freaks out when it is mentioned in the config files. So let's
just remove the GSSAPI-stuff.

Signed-off-by: Dennis Eriksen <[email protected]>
2022-11-08 09:12:18 +01:00
dev-sec CI e32d550e9b update changelog 2022-11-04 11:03:08 +00:00
Dennis Eriksen 4df95e3733 OpenBSD does not set distributiuon_major_version (#597)
This role fails with `The task includes an option with an undefined variable` on OpenBSD because `distributiuon_major_version` is not set on OpenBSD.

We should either default to "" if the variable is not set, or remove `vars/OpenBSD.yml`. I would prefer the former :)

Signed-off-by: Dennis Eriksen <[email protected]>

Signed-off-by: Dennis Eriksen <[email protected]>
2022-11-04 12:00:55 +01:00
dev-sec CI 05205eb413 update changelog 2022-11-01 17:13:21 +00:00
schurzi d0407b17c4 Merge pull request #596 from dev-sec/templates
add Ansible specific templates for issues
2022-11-01 18:10:59 +01:00
Martin Schurz 1346e37e14 actually add templates ...
Signed-off-by: Martin Schurz <[email protected]>
2022-10-28 10:26:00 +02:00
dev-sec CI c2ee3105c7 update changelog 2022-10-28 05:16:41 +00:00
schurzi 613fbd82da use github templates for new issues (#595)
Signed-off-by: Martin Schurz <[email protected]>

Signed-off-by: Martin Schurz <[email protected]>
2022-10-28 07:14:58 +02:00
dev-sec CI 9530615d5f update galaxy.yml with new version 2022-10-27 18:48:57 +00:00
dev-sec CI 24d0153815 update changelog 2022-10-27 18:46:03 +00:00
schurzi 99fe8b6969 Merge pull request #594 from dlouzan/fix/type-cast-variables
fix(os_hardening): cast expected int types in pam tasks
2022-10-27 20:43:17 +02:00
Martin Schurz f496b385dd use github templates for new issues
Signed-off-by: Martin Schurz <[email protected]>
2022-10-27 20:41:06 +02:00
Diego Louzán f8295d5248 fix(os_hardening): cast expected int types in pam tasks
Signed-off-by: Diego Louzán <[email protected]>
2022-10-27 16:50:08 +02:00
dev-sec CI a1f75f877b update changelog 2022-10-26 08:33:13 +00:00
schurzi 901923bac2 Merge pull request #588 from dev-sec/support_more_os
Support more os
2022-10-26 10:13:40 +02:00
Martin Schurz c30ef42355 exclude el9 from vm tests
Signed-off-by: Martin Schurz <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich e2b963d711 change baselines back to master
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich 414efd6125 use correct centos stream images, try to fix prepare step for debian tests
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich 87a461fc57 use forked mysql-baseline
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich dac66f4a88 simplify OS-vars files
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich 3b8b394f10 add ssh-vars for new OS
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:59:11 +02:00
Sebastian Gumprich b27ffd08b0 add mysql-vars for new OS
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-25 18:58:53 +02:00
dev-sec CI 8ee946a537 update changelog 2022-10-24 08:04:42 +00:00
Sebastian Gumprich a176443f22 add support for centos stream 8 and 9, rocky 9
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-24 10:03:07 +02:00
Sebastian Gumprich 9d75e3b00e test crypto changes from ssh-baseline
Signed-off-by: Sebastian Gumprich <[email protected]>
2022-10-24 10:03:07 +02:00
schurzi a1b80fe657 adopt all current suggestions from ansible-lint (#592) 2022-10-24 09:42:23 +02:00
dev-sec CI 53be805099 update changelog 2022-10-21 09:07:46 +00:00
donestefan 464d8df8e8 add hardening of root user account(s) (#579) 2022-10-21 11:05:43 +02:00
53 changed files with 514 additions and 182 deletions

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ exclude_paths:
skip_list: skip_list:
- fqcn-builtins - fqcn-builtins
- name[template]
mock_roles: mock_roles:
- geerlingguy.git - geerlingguy.git
-49
View File
@@ -1,49 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Actual behavior**
<!--- Paste verbatim command output between quotes -->
```paste below
```
**Example Playbook**
<!--- Paste an example playbook that can be used to reproduce the problem between quotes -->
```paste below
```
**OS / Environment**
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
**Ansible Version**
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
```
**Role Version**
<!--- Paste version of the role between quotes -->
```paste below
```
**Additional context**
Add any other context about the problem here.
+97
View File
@@ -0,0 +1,97 @@
---
# reference: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests
name: "Bug report"
description: "Create a report to help us improve."
labels: [
"bug"
]
body:
- type: markdown
attributes:
value: |
Reporting Bugs ld follow some simple rules:
- **Check**, if you can find similar bugs
- **Describe** what is happening and what should happen
- **Explain** how to reproduce the problem
- **Add** more details and attachments
- **Follow up**, if somebody is having questions or needs more details
- type: textarea
id: description
attributes:
label: "Description"
description: Describe the bug
placeholder: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: reprod
attributes:
label: "Reproduction steps"
render: Shell
description: Paste an example playbook that can be used to reproduce the problem. This will be automatically formatted into code, so no need for backticks.
value: |
...
validations:
required: true
- type: textarea
id: currentbehavior
attributes:
label: "Current Behavior"
description: Please describe the results you received
value: |
...
validations:
required: true
- type: textarea
id: expectedbehavior
attributes:
label: "Expected Behavior"
description: Please describe the results you expect
value: |
...
validations:
required: true
- type: textarea
id: os
attributes:
label: "OS / Environment"
value: |
Provide all relevant information below, e.g. target OS versions, network device firmware, etc.
validations:
required: true
- type: textarea
id: ansible
attributes:
label: "Ansible Version"
render: Shell
value: |
Paste verbatim output from "ansible --version" between quotes. This will be automatically formatted into code, so no need for backticks.
validations:
required: true
- type: textarea
id: collection
attributes:
label: "Collection Version"
render: Shell
value: |
Paste version of the collection. This will be automatically formatted into code, so no need for backticks.
validations:
required: true
- type: textarea
id: additional
attributes:
label: "Additional information"
description: Please add information like the used software versions, outputs of logs, OS information, screenshots, etc. to enhance the report
value: |
...
validations:
required: false
-16
View File
@@ -1,16 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,55 @@
---
# reference: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests
name: "Feature request"
description: "Suggest an idea for this project."
labels: [
"enhancement"
]
body:
- type: markdown
attributes:
value: |
Requesting a new feature or enhancement is following some simple rules:
- **Check**, if the feature is already requested
- **Describe** what your feature will bring to the community
- **Explain** the criteria to fulfill the request
- **Add** more details like mock ups, attachments, lists, screenshots
- **Follow Up** in the discussion to the feature
- type: textarea
id: description
attributes:
label: "Description"
description: Is your feature request related to a problem? Please describe.
placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
validations:
required: true
- type: textarea
id: solution
attributes:
label: "Solution"
description: Describe the solution you'd like
placeholder: A clear and concise description of what you want to happen.
validations:
required: false
- type: textarea
id: alternatives
attributes:
label: "Alternatives"
description: Describe alternatives you've considered
placeholder: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: false
- type: textarea
id: additional
attributes:
label: "Additional information"
description: Add any other context or screenshots about the feature request here.
value: |
...
validations:
required: false
+5
View File
@@ -10,3 +10,8 @@ updates:
directory: "/" # Location of package manifests directory: "/" # Location of package manifests
schedule: schedule:
interval: "daily" interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
+2 -2
View File
@@ -37,7 +37,7 @@ jobs:
- debian11 - debian11
# - amazon # geerlingguy.mysql does not support fedora # - amazon # geerlingguy.mysql does not support fedora
# - arch # needs to be fixed # - arch # needs to be fixed
# - opensuse_tumbleweed # needs to be fixed - opensuse_tumbleweed # needs to be fixed
# - fedora # geerlingguy.mysql does not support fedora # - fedora # geerlingguy.mysql does not support fedora
steps: steps:
- name: Checkout repo - name: Checkout repo
@@ -47,7 +47,7 @@ jobs:
submodules: true submodules: true
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
+1 -1
View File
@@ -46,7 +46,7 @@ jobs:
submodules: true submodules: true
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
+1 -1
View File
@@ -45,7 +45,7 @@ jobs:
submodules: true submodules: true
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
+4 -4
View File
@@ -25,17 +25,17 @@ jobs:
matrix: matrix:
molecule_distro: molecule_distro:
- centos7 - centos7
- centosstream8 - centos8s
- centosstream9 # - centos9s # problems with vagrant
- rocky8 - rocky8
- rocky9 # - rocky9 # problems with vagrant
- ubuntu1804 - ubuntu1804
- ubuntu2004 - ubuntu2004
- ubuntu2204 - ubuntu2204
- debian10 - debian10
- debian11 - debian11
# - opensuse42 # opensuse currently cannot get an ip address # - 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: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3
+1 -1
View File
@@ -21,6 +21,6 @@ jobs:
ref: ${{ github.head_ref }} ref: ${{ github.head_ref }}
- name: Prettify code - name: Prettify code
uses: creyD/prettier_action@v3.1 uses: creyD/prettier_action@v4.2
with: with:
prettier_options: --write {**/*,*}.md prettier_options: --write {**/*,*}.md
+1 -1
View File
@@ -46,7 +46,7 @@ jobs:
submodules: true submodules: true
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
@@ -46,7 +46,7 @@ jobs:
submodules: true submodules: true
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
+52 -3
View File
@@ -1,11 +1,58 @@
# Changelog # Changelog
## [8.2.1](https://github.com/dev-sec/ansible-collection-hardening/tree/8.2.1) (2022-10-20) ## [9.0.0](https://github.com/dev-sec/ansible-collection-hardening/tree/9.0.0) (2023-01-19)
[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.4.0...9.0.0)
**Implemented enhancements:**
- Add support for /etc/auditd.conf num\_logs to go with max\_log\_file\_action [\#616](https://github.com/dev-sec/ansible-collection-hardening/issues/616)
- Add support for /etc/auditd.conf num\_logs to go with max\_log\_file\_action [\#617](https://github.com/dev-sec/ansible-collection-hardening/pull/617) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([richardlock](https://github.com/richardlock))
- Parametrize more auditd.conf options [\#535](https://github.com/dev-sec/ansible-collection-hardening/pull/535) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([kravietz](https://github.com/kravietz))
**Merged pull requests:**
- Bump actions/setup-python from 1 to 4 [\#611](https://github.com/dev-sec/ansible-collection-hardening/pull/611) [[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)] ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump creyD/prettier\_action from 3.1 to 4.2 [\#610](https://github.com/dev-sec/ansible-collection-hardening/pull/610) ([dependabot[bot]](https://github.com/apps/dependabot))
## [8.4.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.4.0) (2022-12-17)
[Full Changelog](https://github.com/dev-sec/ansible-collection-hardening/compare/8.3.0...8.4.0)
**Implemented enhancements:**
- Implement Test for MySQL systemd service [\#606](https://github.com/dev-sec/ansible-collection-hardening/issues/606)
- Extended net hardening [\#607](https://github.com/dev-sec/ansible-collection-hardening/pull/607) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([DonEstefan](https://github.com/DonEstefan))
- Add OpenSUSE support [\#605](https://github.com/dev-sec/ansible-collection-hardening/pull/605) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
- Allow ssh\_allow\_tcp\_forwarding to be a boolean [\#600](https://github.com/dev-sec/ansible-collection-hardening/pull/600) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([crisbal](https://github.com/crisbal))
- OpenBSD does not support GSSAPI Authentication [\#598](https://github.com/dev-sec/ansible-collection-hardening/pull/598) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([dennisse](https://github.com/dennisse))
- add Ansible specific templates for issues [\#596](https://github.com/dev-sec/ansible-collection-hardening/pull/596) ([schurzi](https://github.com/schurzi))
- use github templates for new issues [\#595](https://github.com/dev-sec/ansible-collection-hardening/pull/595) ([schurzi](https://github.com/schurzi))
**Fixed bugs:** **Fixed bugs:**
- os\_auth\_retries variable causes a comparison type error on pam tasks [\#593](https://github.com/dev-sec/ansible-collection-hardening/issues/593)
- ssh\_hardening: Install selinux dependencies fails on Oracle Linux \(RHEL\) 9 [\#585](https://github.com/dev-sec/ansible-collection-hardening/issues/585)
- OpenBSD does not set distributiuon\_major\_version [\#597](https://github.com/dev-sec/ansible-collection-hardening/pull/597) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([dennisse](https://github.com/dennisse))
**Merged pull requests:**
- Check for github action updates daily [\#609](https://github.com/dev-sec/ansible-collection-hardening/pull/609) ([jlosito](https://github.com/jlosito))
- add verify-task to check if mysql is running and enabled [\#608](https://github.com/dev-sec/ansible-collection-hardening/pull/608) [[mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/mysql_hardening)] ([rndmh3ro](https://github.com/rndmh3ro))
- Updates handlers for new ansible syntax and deprecated options for legacy commands [\#602](https://github.com/dev-sec/ansible-collection-hardening/pull/602) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([jsievertde](https://github.com/jsievertde))
- add notice to sign-off work to contributor guideline [\#601](https://github.com/dev-sec/ansible-collection-hardening/pull/601) ([schurzi](https://github.com/schurzi))
## [8.3.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.3.0) (2022-10-27)
[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:**
- cast expected int types in pam tasks [\#594](https://github.com/dev-sec/ansible-collection-hardening/pull/594) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([dlouzan](https://github.com/dlouzan))
- do not manage trusted user ca keys if none exist [\#580](https://github.com/dev-sec/ansible-collection-hardening/pull/580) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([hollow](https://github.com/hollow)) - do not manage trusted user ca keys if none exist [\#580](https://github.com/dev-sec/ansible-collection-hardening/pull/580) [[ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/ssh_hardening)] ([hollow](https://github.com/hollow))
**Closed issues:** **Closed issues:**
@@ -16,6 +63,8 @@
**Merged pull requests:** **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)) - 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) ## [8.2.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.2.0) (2022-09-08)
@@ -43,7 +92,7 @@
**Merged pull requests:** **Merged pull requests:**
- update supported OS in meta and fix linting [\#572](https://github.com/dev-sec/ansible-collection-hardening/pull/572) [[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)) - update supported OS in meta and fix linting [\#572](https://github.com/dev-sec/ansible-collection-hardening/pull/572) [[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))
- fix misleading comment [\#571](https://github.com/dev-sec/ansible-collection-hardening/pull/571) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([donestefan](https://github.com/donestefan)) - fix misleading comment [\#571](https://github.com/dev-sec/ansible-collection-hardening/pull/571) [[os_hardening](https://github.com/dev-sec/ansible-collection-hardening/labels/os_hardening)] ([DonEstefan](https://github.com/DonEstefan))
- only run release actions on upstream-repo [\#568](https://github.com/dev-sec/ansible-collection-hardening/pull/568) ([rndmh3ro](https://github.com/rndmh3ro)) - only run release actions on upstream-repo [\#568](https://github.com/dev-sec/ansible-collection-hardening/pull/568) ([rndmh3ro](https://github.com/rndmh3ro))
## [8.0.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.0.0) (2022-08-22) ## [8.0.0](https://github.com/dev-sec/ansible-collection-hardening/tree/8.0.0) (2022-08-22)
+19 -1
View File
@@ -15,7 +15,7 @@ In order to contribute code please:
1. Fork the project on GitHub 1. Fork the project on GitHub
2. Clone the project 2. Clone the project
3. Add changes (and tests) 3. Add changes (and tests)
4. Commit and push 4. Commit, sign off and push your changes
5. Create a merge-request 5. Create a merge-request
To have your code merged, see the expectations listed below. To have your code merged, see the expectations listed below.
@@ -28,6 +28,24 @@ Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCom
## Expectations ## Expectations
## Sign off Your Work
The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project.
[Here is the full text of the DCO](http://developercertificate.org/).
Contributors must sign-off that they adhere to these requirements by adding a `Signed-off-by` line to commit messages.
```text
This is my commit message
Signed-off-by: Random J Developer <[email protected]>
```
Git even has a -s command line option to append this automatically to your commit message:
```text
git commit -s -m 'This is my commit message'
```
### Don't reinvent the wheel ### Don't reinvent the wheel
This hardening project doesn't intend to reinvent the configuration stack for services. Aim to use official configuration projects first and provide hardening as a layer on top. The goal is remove the need for a user to configure all aspects of services and maintain security configuration. This way, the user can still configure a service using the interface provided by the official project. This hardening project doesn't intend to reinvent the configuration stack for services. Aim to use official configuration projects first and provide hardening as a layer on top. The goal is remove the need for a user to configure all aspects of services and maintain security configuration. This way, the user can still configure a service using the interface provided by the official project.
+1 -1
View File
@@ -1,6 +1,6 @@
namespace: devsec namespace: devsec
name: hardening name: hardening
version: 8.2.0 version: 8.4.0
readme: README.md readme: README.md
authors: authors:
- dev-sec <[email protected]> - dev-sec <[email protected]>
+7
View File
@@ -24,6 +24,13 @@
- mysql_python_package_debian is not defined - mysql_python_package_debian is not defined
- ansible_distribution != "Ubuntu" - ansible_distribution != "Ubuntu"
- ansible_distribution_major_version|int < 20 - ansible_distribution_major_version|int < 20
- name: Use Python 3 on Suse
set_fact:
ansible_python_interpreter: /usr/bin/python3
when:
- ansible_os_family == 'Suse'
- include_role: - include_role:
name: mysql_hardening name: mysql_hardening
vars: vars:
+2
View File
@@ -25,6 +25,8 @@ platforms:
container: docker container: docker
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
config_options: config_options:
defaults: defaults:
interpreter_python: auto_silent interpreter_python: auto_silent
+9 -6
View File
@@ -15,6 +15,12 @@
- ansible_distribution == 'Debian' - ansible_distribution == 'Debian'
- ansible_distribution_major_version|int >= 11 - ansible_distribution_major_version|int >= 11
- name: Use Python 3 on Suse
set_fact:
ansible_python_interpreter: /usr/bin/python3
when:
- ansible_os_family == 'Suse'
- name: Use Python 2 on Debian 10 - name: Use Python 2 on Debian 10
set_fact: set_fact:
ansible_python_interpreter: /usr/bin/python ansible_python_interpreter: /usr/bin/python
@@ -29,11 +35,9 @@
update_cache: true update_cache: true
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: install required tools on SuSE - name: Install required python packages on Suse
community.general.zypper: ansible.builtin.shell: zypper -n install python-xml python3-rpm python3-PyMySQL
name: "python-xml" when: ansible_os_family == 'Suse'
state: present
when: ansible_facts.os_family == 'Suse'
- name: create missing directory - name: create missing directory
file: file:
@@ -56,7 +60,6 @@
- ansible_distribution != "Ubuntu" - ansible_distribution != "Ubuntu"
- ansible_distribution_major_version|int < 20 - ansible_distribution_major_version|int < 20
- include_role: - include_role:
name: dev-sec.mysql name: dev-sec.mysql
+3
View File
@@ -34,6 +34,9 @@
update_cache: true update_cache: true
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian'
- name: include tests for the service
include_tasks: verify_tasks/service.yml
- name: download cinc-auditor - name: download cinc-auditor
get_url: get_url:
url: https://omnitruck.cinc.sh/install.sh url: https://omnitruck.cinc.sh/install.sh
@@ -0,0 +1,16 @@
---
- name: Load variables from role to use the "mysql_daemon" variable
ansible.builtin.include_role:
name: devsec.hardening.mysql_hardening
apply:
tags:
- never
- name: Populate service facts
ansible.builtin.service_facts:
- name: Check if MySQL is running and enabled
assert:
that:
- "ansible_facts.services[mysql_daemon + '.service'].state == 'running'"
- "ansible_facts.services[mysql_daemon + '.service'].status == 'enabled'"
+2
View File
@@ -25,6 +25,8 @@ platforms:
container: docker container: docker
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
config_options: config_options:
defaults: defaults:
interpreter_python: auto_silent interpreter_python: auto_silent
+1
View File
@@ -17,6 +17,7 @@
vars: vars:
os_security_users_allow: change_user os_security_users_allow: change_user
os_security_kernel_enable_core_dump: false os_security_kernel_enable_core_dump: false
os_auditd_num_logs: 10
os_security_suid_sgid_remove_from_unknown: true os_security_suid_sgid_remove_from_unknown: true
os_auth_pam_passwdqc_enable: false os_auth_pam_passwdqc_enable: false
os_auth_lockout_time: 15 os_auth_lockout_time: 15
+2
View File
@@ -25,6 +25,8 @@ platforms:
container: docker container: docker
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
config_options: config_options:
defaults: defaults:
interpreter_python: auto_silent interpreter_python: auto_silent
+2
View File
@@ -14,6 +14,8 @@ platforms:
cpus: 2 cpus: 2
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
env: env:
ANSIBLE_PIPELINING: "True" ANSIBLE_PIPELINING: "True"
config_options: config_options:
-2
View File
@@ -16,8 +16,6 @@
- name: Run the equivalent of "apt-get update && apt-get upgrade" - name: Run the equivalent of "apt-get update && apt-get upgrade"
apt: apt:
name: "*"
state: latest
update_cache: true update_cache: true
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
+2
View File
@@ -25,6 +25,8 @@ platforms:
container: docker container: docker
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
config_options: config_options:
defaults: defaults:
interpreter_python: auto_silent interpreter_python: auto_silent
+1 -1
View File
@@ -42,7 +42,7 @@
shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4" shell: "bash /tmp/install.sh -s -- -P cinc-auditor -v 4"
- name: Execute cinc-auditor tests - name: Execute cinc-auditor tests
command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/ssh-baseline/archive/refs/heads/simplify_crypto.zip" command: "/opt/cinc-auditor/bin/cinc-auditor exec --no-show-progress --no-color --no-distinct-exit https://github.com/dev-sec/ssh-baseline/archive/refs/heads/master.zip"
register: test_results register: test_results
changed_when: false changed_when: false
ignore_errors: true ignore_errors: true
@@ -25,6 +25,8 @@ platforms:
container: docker container: docker
provisioner: provisioner:
name: ansible name: ansible
options:
diff: true
config_options: config_options:
defaults: defaults:
interpreter_python: auto_silent interpreter_python: auto_silent
+1
View File
@@ -16,6 +16,7 @@ It configures:
- Ansible 2.9.0 - Ansible 2.9.0
- An existing MySQL installation - An existing MySQL installation
- python-jmespath on the ansible host
### Example playbook ### Example playbook
+4 -2
View File
@@ -59,12 +59,14 @@
- mysql_version.version.full is version('8.0.3', '>=') - mysql_version.version.full is version('8.0.3', '>=')
- mysql_distribution == "mysql" - mysql_distribution == "mysql"
- include: configure.yml - name: Include tasks for configuration
import_tasks: configure.yml
when: mysql_hardening_enabled | bool when: mysql_hardening_enabled | bool
tags: tags:
- mysql_hardening - 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 when: mysql_hardening_enabled | bool
tags: tags:
- mysql_hardening - mysql_hardening
@@ -4,7 +4,7 @@
msg: 'ERROR - you have to change default mysql_root_password' msg: 'ERROR - you have to change default mysql_root_password'
when: mysql_root_password == '-----====>SetR00tPa$$wordH3r3!!!<====-----' 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: community.mysql.mysql_user:
name: 'root' name: 'root'
host_all: true host_all: true
@@ -19,14 +19,14 @@
mode: '0400' mode: '0400'
tags: my_cnf tags: my_cnf
- name: ensure that the test database is absent - name: Ensure that the test database is absent
community.mysql.mysql_db: community.mysql.mysql_db:
name: test name: test
state: absent state: absent
login_unix_socket: "{{ login_unix_socket | default(omit) }}" login_unix_socket: "{{ login_unix_socket | default(omit) }}"
when: mysql_remove_test_database when: mysql_remove_test_database
- name: ensure that anonymous users are absent - name: Ensure that anonymous users are absent
community.mysql.mysql_user: community.mysql.mysql_user:
name: '' name: ''
state: absent state: absent
@@ -34,7 +34,7 @@
login_unix_socket: "{{ login_unix_socket | default(omit) }}" login_unix_socket: "{{ login_unix_socket | default(omit) }}"
when: mysql_remove_anonymous_users 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: community.mysql.mysql_query:
query: query:
- DELETE - DELETE
@@ -46,7 +46,7 @@
login_unix_socket: "{{ login_unix_socket | default(omit) }}" login_unix_socket: "{{ login_unix_socket | default(omit) }}"
when: mysql_remove_remote_root 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: community.mysql.mysql_query:
query: query:
- SELECT GROUP_CONCAT(QUOTE(USER), '@', QUOTE(HOST) SEPARATOR ', ') AS users - 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 == "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', '>=')) (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: community.mysql.mysql_query:
query: query:
- SELECT GROUP_CONCAT(QUOTE(USER), '@', QUOTE(HOST) SEPARATOR ', ') AS users - 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 == "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', '<')) (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: set_fact:
users_wo_auth: "{{ mysql_users_wo_passwords_or_auth_string.query_result.0.0 | community.general.json_query('users') }}" users_wo_auth: "{{ mysql_users_wo_passwords_or_auth_string.query_result.0.0 | community.general.json_query('users') }}"
when: when:
- mysql_users_wo_passwords_or_auth_string.query_result is defined - mysql_users_wo_passwords_or_auth_string.query_result is defined
- mysql_users_wo_passwords_or_auth_string.query_result != "" # noqa empty-string-compare - 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: set_fact:
users_wo_auth: "{{ mysql_users_wo_passwords.query_result.0.0 | community.general.json_query('users') }}" users_wo_auth: "{{ mysql_users_wo_passwords.query_result.0.0 | community.general.json_query('users') }}"
when: when:
- mysql_users_wo_passwords.query_result is defined - mysql_users_wo_passwords.query_result is defined
- mysql_users_wo_passwords.query_result != "" # noqa empty-string-compare - 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: community.mysql.mysql_query:
query: query:
- "DROP USER {{ users_wo_auth }}" - "DROP USER {{ users_wo_auth }}"
+1 -1
View File
@@ -1,5 +1,5 @@
--- ---
mysql_daemon: mysql mysql_daemon: mariadb
mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf' mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d' mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
+10
View File
@@ -0,0 +1,10 @@
---
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/my.cnf.d/*.cnf files
mysql_cnf_group: 'mysql' # owner of /etc/my.cnf.d/*.cnf files
mysql_hardening_group: 'mysql'
login_unix_socket: '/run/mysql/mysql.sock'
+37 -1
View File
@@ -218,6 +218,9 @@ We know that this is the case on Raspberry Pi.
- `os_auditd_max_log_file` - `os_auditd_max_log_file`
- Default: `6` - Default: `6`
- Description: This keyword specifies the maximum file size in megabytes. When this limit is reached, it will trigger a configurable action. The value given must be numeric. - Description: This keyword specifies the maximum file size in megabytes. When this limit is reached, it will trigger a configurable action. The value given must be numeric.
- `os_auditd_num_logs`
- Default: `5`
- Description: This keyword specifies the number of log files to keep if `rotate` is given as the max_log_file_action. The value given must be numeric.
- `hidepid_option` - `hidepid_option`
- Default: `2` (on RHEL/CentOS7 `0`, see known limitations) - Default: `2` (on RHEL/CentOS7 `0`, see known limitations)
- Description: `0`: This is the default setting and gives you the default behaviour. `1`: With this option an normal user would not see other processes but their own about ps, top etc, but he is still able to see process IDs in /proc. `2`: Users are only able too see their own processes (like with hidepid=1), but also the other process IDs are hidden for them in /proc. - Description: `0`: This is the default setting and gives you the default behaviour. `1`: With this option an normal user would not see other processes but their own about ps, top etc, but he is still able to see process IDs in /proc. `2`: Users are only able too see their own processes (like with hidepid=1), but also the other process IDs are hidden for them in /proc.
@@ -230,6 +233,15 @@ We know that this is the case on Raspberry Pi.
- `os_ignore_home_folder_users` - `os_ignore_home_folder_users`
- Default: `lost+found` - Default: `lost+found`
- Description: specify user home folders in `/home` that shouldn't be chmodded to 700 - 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` - `os_cron_enabled`
- Default: `true` - Default: `true`
- Description: Set to false to disable installing and configuring cron. - Description: Set to false to disable installing and configuring cron.
@@ -241,7 +253,7 @@ We know that this is the case on Raspberry Pi.
- Description: Set to false to disable installing and configuring limits. - Description: Set to false to disable installing and configuring limits.
- `os_login_defs_enabled` - `os_login_defs_enabled`
- Default: `true` - 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` - `os_minimize_access_enabled`
- Default: `true` - Default: `true`
- Description: Set to false to disable installing and configuring minimize_access. - Description: Set to false to disable installing and configuring minimize_access.
@@ -287,6 +299,30 @@ We know that this is the case on Raspberry Pi.
- `os_sha_crypt_max_rounds` - `os_sha_crypt_max_rounds`
- Default: `640000` - Default: `640000`
- Description: Define the number of maximum SHA rounds. With a lot of rounds brute forcing the password is more difficult. But note also that it more CPU resources will be needed to authenticate users. The values must be inside the 1000-999999999 range. - Description: Define the number of maximum SHA rounds. With a lot of rounds brute forcing the password is more difficult. But note also that it more CPU resources will be needed to authenticate users. The values must be inside the 1000-999999999 range.
- `os_auditd_enabled`
- Default: `true`
- Description: Set to false to disable installing and configuring `auditd`.
- `os_auditd_flush`
- Default: `INCREMENTAL`
- Description: Valid values are none, incremental, incremental_async, data, and sync.
- `os_auditd_max_log_file`
- Default: 6
- Description: This keyword specifies the maximum file size in megabytes. When this limit is reached, it will trigger a configurable action.
- `os_auditd_max_log_file_action`
- Default: `keep_logs`
- Description: This parameter tells the system what action to take when the system has detected that the max file size limit has been reached. Valid values are ignore, syslog, suspend, rotate and keep_logs.
- `os_auditd_admin_space_left`
- Default: 50
- Description: This is a numeric value in megabytes that tells the audit daemon when to perform a configurable action because the system is running low on disk space.
- `os_auditd_space_left`
- Default: 75
- Description: If the free space in the filesystem containing log_file drops below this value, the audit daemon takes the action specified by space_left_action.
- `os_auditd_space_left_action`
- Default: SYSLOG
- Description: This parameter tells the system what action to take when the system has detected that it is starting to get low on disk space.
- `os_auditd_log_format`
- Default: `RAW`
- Description: The log format describes how the information should be stored on disk. There are 2 options: raw and enriched. If set to `RAW`, the audit records will be stored in a format exactly as the kernel sends it. The `ENRICHED` option will resolve all uid, gid, syscall, architecture, and socket address information before writing the event to disk. This aids in making sense of events created on one system but reported/analyzed on another system.
- `os_mnt_boot_dir_mode` - `os_mnt_boot_dir_mode`
- Default: `0700` - Default: `0700`
- Description: Set default perimissions for /boot - Description: Set default perimissions for /boot
+22 -2
View File
@@ -15,13 +15,21 @@ os_auth_root_ttys: [console, tty1, tty2, tty3, tty4, tty5, tty6]
os_chfn_restrict: '' 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 os_chmod_home_folders: true
# May contain: change_user # May contain: change_user
os_security_users_allow: [] os_security_users_allow: []
# Specify user home folders in /home that shouldn't be chmodded to 700 # Specify user home folders in /home that shouldn't be chmodded to 700
os_ignore_home_folder_users: ['lost+found'] 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 # Specify system accounts whose login should not be disabled and password not changed
os_ignore_users: ['vagrant', 'kitchen'] os_ignore_users: ['vagrant', 'kitchen']
os_security_kernel_enable_module_loading: true os_security_kernel_enable_module_loading: true
@@ -253,6 +261,7 @@ sysctl_config:
# Disable acceptance of IPv6 router solicitations messages | sysctl-21 # Disable acceptance of IPv6 router solicitations messages | sysctl-21
net.ipv6.conf.default.router_solicitations: 0 net.ipv6.conf.default.router_solicitations: 0
net.ipv6.conf.all.router_solicitations: 0
# Disable Accept Router Preference from router advertisement | sysctl-22 # Disable Accept Router Preference from router advertisement | sysctl-22
net.ipv6.conf.default.accept_ra_rtr_pref: 0 net.ipv6.conf.default.accept_ra_rtr_pref: 0
@@ -265,6 +274,7 @@ sysctl_config:
# Disable IPv6 autoconfiguration | sysctl-26 # Disable IPv6 autoconfiguration | sysctl-26
net.ipv6.conf.default.autoconf: 0 net.ipv6.conf.default.autoconf: 0
net.ipv6.conf.all.autoconf: 0
# Disable neighbor solicitations to send out per address | sysctl-27 # Disable neighbor solicitations to send out per address | sysctl-27
net.ipv6.conf.default.dad_transmits: 0 net.ipv6.conf.default.dad_transmits: 0
@@ -318,8 +328,18 @@ os_hardening_enabled: true
# Set to false to disable installing and configuring auditd. # Set to false to disable installing and configuring auditd.
os_auditd_enabled: true os_auditd_enabled: true
os_auditd_flush: INCREMENTAL
os_auditd_max_log_file: 6 os_auditd_max_log_file: 6
os_auditd_max_log_file_action: keep_logs os_auditd_max_log_file_action: keep_logs
os_auditd_log_format: RAW
os_auditd_admin_space_left: 50
os_auditd_space_left: 75
os_auditd_space_left_action: SYSLOG
os_auditd_admin_space_left_action: SUSPEND
os_auditd_disk_full_action: SUSPEND
os_auditd_disk_error_action: SUSPEND
os_auditd_log_group: root
os_auditd_num_logs: 5
# Set the SELinux state, which can be either disabled, permissive, or enforcing. # Set the SELinux state, which can be either disabled, permissive, or enforcing.
os_selinux_state: enforcing os_selinux_state: enforcing
@@ -338,7 +358,7 @@ os_ctrlaltdel_disabled: false
# Set to false to disable installing and configuring limits. # Set to false to disable installing and configuring limits.
os_limits_enabled: true 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 os_login_defs_enabled: true
# Set to false to disable installing and configuring minimize_access. # Set to false to disable installing and configuring minimize_access.
+5 -6
View File
@@ -1,19 +1,18 @@
--- ---
- name: Update-initramfs - name: Update-initramfs
command: 'update-initramfs -u' ansible.builtin.command: 'update-initramfs -u'
- name: restart-auditd - name: Restart auditd
command: ansible.builtin.command:
cmd: 'service auditd restart' # rhel: see: https://access.redhat.com/solutions/2664811 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'
when: molecule_yml is not defined # restarting auditd in a container does not work when: molecule_yml is not defined # restarting auditd in a container does not work
- name: Reload systemd - name: Reload systemd
systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
- name: Remount filesystems - name: Remount filesystems
mount: ansible.posix.mount:
path: "{{ item }}" path: "{{ item }}"
state: remounted state: remounted
loop: "{{ mountpoints_changed }}" loop: "{{ mountpoints_changed }}"
+1 -1
View File
@@ -12,5 +12,5 @@
owner: 'root' owner: 'root'
group: 'root' group: 'root'
mode: '0640' mode: '0640'
notify: 'restart-auditd' notify: Restart auditd
tags: auditd tags: auditd
+36 -18
View File
@@ -22,79 +22,97 @@
with_dict: '{{ os_vars }}' with_dict: '{{ os_vars }}'
tags: always tags: always
- import_tasks: auditd.yml - name: Import tasks for auditd
import_tasks: auditd.yml
tags: auditd tags: auditd
when: os_auditd_enabled | bool when: os_auditd_enabled | bool
- import_tasks: cron.yml - name: Import tasks for cron
import_tasks: cron.yml
tags: cron tags: cron
when: os_cron_enabled | bool when: os_cron_enabled | bool
- import_tasks: ctrlaltdel.yml - name: Import tasks to configure ctrl+alt+del
import_tasks: ctrlaltdel.yml
tags: ctrlaltdel tags: ctrlaltdel
when: os_ctrlaltdel_disabled | bool when: os_ctrlaltdel_disabled | bool
- import_tasks: limits.yml - name: Import tasks to configure limits
import_tasks: limits.yml
tags: limits tags: limits
when: os_limits_enabled | bool 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 tags: login_defs
when: os_login_defs_enabled | bool 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 tags: minimize_access
when: os_minimize_access_enabled | bool when: os_minimize_access_enabled | bool
- import_tasks: pam.yml - name: Import tasks to configure PAM
import_tasks: pam.yml
tags: pam tags: pam
when: os_pam_enabled | bool when: os_pam_enabled | bool
- import_tasks: modprobe.yml - name: Import tasks to configure modules
import_tasks: modprobe.yml
tags: modprobe tags: modprobe
when: os_modprobe_enabled | bool when: os_modprobe_enabled | bool
- import_tasks: profile.yml - name: Import tasks to configure profile
import_tasks: profile.yml
tags: profile tags: profile
when: os_profile_enabled | bool when: os_profile_enabled | bool
- import_tasks: securetty.yml - name: Import tasks to configure securetty
import_tasks: securetty.yml
tags: securetty tags: securetty
when: os_securetty_enabled | bool 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 when: os_security_suid_sgid_enforce | bool
tags: suid_sgid tags: suid_sgid
- import_tasks: sysctl.yml - name: Import tasks to configure sysctl
import_tasks: sysctl.yml
tags: sysctl tags: sysctl
when: os_sysctl_enabled | bool 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 tags: user_accounts
when: os_user_accounts_enabled | bool when: os_user_accounts_enabled | bool
- import_tasks: rhosts.yml - name: Import tasks to configure rhosts
import_tasks: rhosts.yml
tags: rhosts tags: rhosts
when: os_rhosts_enabled | bool when: os_rhosts_enabled | bool
- import_tasks: netrc.yml - name: Import tasks to configure netrc
import_tasks: netrc.yml
tags: netrc tags: netrc
when: os_netrc_enabled | bool when: os_netrc_enabled | bool
- import_tasks: yum.yml - name: Import tasks to configure yum
import_tasks: yum.yml
tags: yum tags: yum
when: when:
- ansible_facts.os_family == 'RedHat' - ansible_facts.os_family == 'RedHat'
- os_yum_enabled | bool - os_yum_enabled | bool
- import_tasks: apt.yml - name: Import tasks to configure apt
import_tasks: apt.yml
tags: apt tags: apt
when: when:
- ansible_facts.os_family == 'Debian' - ansible_facts.os_family == 'Debian'
- os_apt_enabled | bool - os_apt_enabled | bool
- import_tasks: selinux.yml - name: Import tasks to configure selinux
import_tasks: selinux.yml
tags: selinux tags: selinux
when: when:
- ansible_facts.selinux.status == 'enabled' - ansible_facts.selinux.status == 'enabled'
+6 -7
View File
@@ -1,5 +1,6 @@
--- ---
- name: disable coredumps - name: Disable coredumps
when: not os_security_kernel_enable_core_dump | bool
block: block:
- name: Create limits.d-directory if it does not exist | sysctl-31a, sysctl-31b - name: Create limits.d-directory if it does not exist | sysctl-31a, sysctl-31b
file: file:
@@ -28,7 +29,7 @@
modification_time: preserve modification_time: preserve
access_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: file:
path: '/etc/systemd/coredump.conf.d' path: '/etc/systemd/coredump.conf.d'
owner: root owner: root
@@ -37,7 +38,7 @@
state: directory state: directory
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: create custom.conf for disabling coredumps - name: Create custom.conf for disabling coredumps
template: template:
src: 'etc/systemd/coredump.conf.d/coredumps.conf.j2' src: 'etc/systemd/coredump.conf.d/coredumps.conf.j2'
dest: '/etc/systemd/coredump.conf.d/custom.conf' dest: '/etc/systemd/coredump.conf.d/custom.conf'
@@ -47,9 +48,8 @@
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
notify: Reload systemd notify: Reload systemd
when: not os_security_kernel_enable_core_dump | bool - name: Enable coredumps
when: os_security_kernel_enable_core_dump | bool
- name: enable coredumps
block: block:
- name: Remove coredump.conf.d directory with files - name: Remove coredump.conf.d directory with files
file: file:
@@ -62,4 +62,3 @@
file: file:
path: /etc/security/limits.d/10.hardcore.conf path: /etc/security/limits.d/10.hardcore.conf
state: absent state: absent
when: os_security_kernel_enable_core_dump | bool
+2 -1
View File
@@ -1,5 +1,6 @@
--- ---
- include_tasks: hardening.yml - name: Include hardening tasks
include_tasks: hardening.yml
when: os_hardening_enabled | bool when: os_hardening_enabled | bool
tags: tags:
- always - always
+4 -2
View File
@@ -17,11 +17,13 @@
when: when:
- ansible_facts.os_family != 'Archlinux' - ansible_facts.os_family != 'Archlinux'
- import_tasks: pam_debian.yml - name: Import tasks for Debian PAM
import_tasks: pam_debian.yml
when: when:
- ansible_facts.os_family == 'Debian' - ansible_facts.os_family == 'Debian'
- import_tasks: pam_rhel.yml - name: Import tasks for RedHat PAM
import_tasks: pam_rhel.yml
when: when:
- ansible_facts.os_family == 'RedHat' - ansible_facts.os_family == 'RedHat'
+14 -14
View File
@@ -22,9 +22,12 @@
name: 'libpam-modules' name: 'libpam-modules'
state: 'present' state: 'present'
when: when:
- os_auth_retries > 0 - os_auth_retries|int > 0
- name: Manage tally on Debian stable - 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: block:
- name: Configure tally2 - name: Configure tally2
template: template:
@@ -34,26 +37,26 @@
owner: 'root' owner: 'root'
group: 'root' group: 'root'
when: when:
- os_auth_retries > 0 - os_auth_retries|int > 0
- name: Delete tally2 when retries is 0 - name: Delete tally2 when retries is 0
file: file:
path: '{{ tally2_path }}' path: '{{ tally2_path }}'
state: 'absent' state: 'absent'
when: when:
- os_auth_retries == 0 - os_auth_retries|int == 0
when:
- "'libpam-modules' in ansible_facts.packages"
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '<')"
- name: Manage tally/faillock on Debian unstable - 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: block:
- name: Delete tally2 - name: Delete tally2
file: file:
path: '{{ tally2_path }}' path: '{{ tally2_path }}'
state: 'absent' state: 'absent'
- name: create tally directory - name: Create tally directory
file: file:
path: '/var/run/faillock' path: '/var/run/faillock'
state: 'directory' state: 'directory'
@@ -77,7 +80,7 @@
owner: 'root' owner: 'root'
group: 'root' group: 'root'
when: when:
- os_auth_retries > 0 - os_auth_retries|int > 0
- name: Configure faillock pam authfail - name: Configure faillock pam authfail
template: template:
@@ -87,24 +90,21 @@
owner: 'root' owner: 'root'
group: 'root' group: 'root'
when: when:
- os_auth_retries > 0 - os_auth_retries|int > 0
- name: Delete faillock when retries is 0 - name: Delete faillock when retries is 0
file: file:
path: '/usr/share/pam-configs/faillock' path: '/usr/share/pam-configs/faillock'
state: 'absent' state: 'absent'
when: when:
- os_auth_retries == 0 - os_auth_retries|int == 0
- name: Delete faillock authfail when retries is 0 - name: Delete faillock authfail when retries is 0
file: file:
path: '/usr/share/pam-configs/faillock_authfail' path: '/usr/share/pam-configs/faillock_authfail'
state: 'absent' state: 'absent'
when: when:
- os_auth_retries == 0 - os_auth_retries|int == 0
when:
- "'libpam-modules' in ansible_facts.packages"
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '>=')"
- name: Update pam on Debian systems - name: Update pam on Debian systems
command: 'pam-auth-update --package' command: 'pam-auth-update --package'
+1 -1
View File
@@ -42,6 +42,7 @@
register: initramfs register: initramfs
- name: Change sysctls - name: Change sysctls
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
block: block:
- name: Create a combined sysctl-dict if os-dependent sysctls are defined - name: Create a combined sysctl-dict if os-dependent sysctls are defined
set_fact: set_fact:
@@ -69,7 +70,6 @@
ignoreerrors: true ignoreerrors: true
with_dict: '{{ sysctl_config }}' with_dict: '{{ sysctl_config }}'
when: item.key not in sysctl_unsupported_entries | default() when: item.key not in sysctl_unsupported_entries | default()
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
- name: Apply ufw defaults - name: Apply ufw defaults
template: template:
+44 -3
View File
@@ -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 - name: Get UID_MIN from login.defs
shell: awk '/^\s*UID_MIN\s*([0-9]*).*?$/ {print $2}' /etc/login.defs shell: awk '/^\s*UID_MIN\s*([0-9]*).*?$/ {print $2}' /etc/login.defs
args: args:
@@ -25,7 +66,7 @@
when: uid_max is not defined when: uid_max is not defined
- name: Get all system accounts - 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: args:
removes: /etc/passwd removes: /etc/passwd
changed_when: false changed_when: false
@@ -46,7 +87,7 @@
with_community.general.flattened: with_community.general.flattened:
- '{{ sys_accs_cond | default([]) | difference(os_ignore_users) | list }}' - '{{ 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: find:
paths: /home/ paths: /home/
recurse: false recurse: false
@@ -55,7 +96,7 @@
register: home_directories register: home_directories
when: os_chmod_home_folders | bool when: os_chmod_home_folders | bool
- name: set ownership of /home directories to 0700 - name: Set ownership of /home directories to 0700
file: file:
mode: 0700 mode: 0700
path: "{{ item.path }}" path: "{{ item.path }}"
@@ -2,30 +2,26 @@
# Generated by Ansible role {{ ansible_role_name }} # Generated by Ansible role {{ ansible_role_name }}
log_file = /var/log/audit/audit.log log_file = /var/log/audit/audit.log
log_format = RAW log_format = {{ os_auditd_log_format }}
log_group = root log_group = {{ os_auditd_log_group }}
priority_boost = 4 priority_boost = 4
flush = INCREMENTAL flush = {{ os_auditd_flush }}
freq = 20 freq = 20
num_logs = 5 num_logs = {{ os_auditd_num_logs }}
disp_qos = lossy disp_qos = lossy
dispatcher = /sbin/audispd dispatcher = /sbin/audispd
name_format = NONE name_format = NONE
##name = mydomain
max_log_file = {{ os_auditd_max_log_file }} max_log_file = {{ os_auditd_max_log_file }}
max_log_file_action = {{ os_auditd_max_log_file_action }} max_log_file_action = {{ os_auditd_max_log_file_action }}
space_left = 75 space_left = {{ os_auditd_space_left }}
space_left_action = SYSLOG space_left_action = {{ os_auditd_space_left_action }}
action_mail_acct = root action_mail_acct = root
admin_space_left = 50 admin_space_left = {{ os_auditd_admin_space_left }}
admin_space_left_action = SUSPEND admin_space_left_action = {{ os_auditd_admin_space_left_action }}
disk_full_action = SUSPEND disk_full_action = {{ os_auditd_disk_full_action }}
disk_error_action = SUSPEND disk_error_action = {{ os_auditd_disk_error_action }}
##tcp_listen_port =
tcp_listen_queue = 5 tcp_listen_queue = 5
tcp_max_per_addr = 1 tcp_max_per_addr = 1
##tcp_client_ports = 1024-65535
tcp_client_max_idle = 0 tcp_client_max_idle = 0
enable_krb5 = no enable_krb5 = no
krb5_principal = auditd krb5_principal = auditd
##krb5_key_file = /etc/audit/audit.key
@@ -4,7 +4,7 @@
#%PAM-1.0 #%PAM-1.0
auth required pam_env.so auth required pam_env.so
auth required pam_faildelay.so delay=2000000 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 }} auth required pam_faillock.so preauth silent audit even_deny_root deny={{ os_auth_retries }} unlock_time={{ os_auth_lockout_time }}
{% endif %} {% endif %}
{% if (os_auth_pam_sssd_enable | bool) %} {% 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 [default=1 ignore=ignore success=ok] pam_succeed_if.so uid >= 1000 quiet
auth sufficient pam_sss.so forward_pass auth sufficient pam_sss.so forward_pass
{% endif %} {% 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 }} auth required pam_faillock.so authfail audit even_deny_root deny={{ os_auth_retries }} unlock_time={{ os_auth_lockout_time }}
{% endif %} {% endif %}
auth required pam_deny.so auth required pam_deny.so
{% if os_auth_retries > 0 %} {% if os_auth_retries|int > 0 %}
account required pam_faillock.so account required pam_faillock.so
{% endif %} {% endif %}
account required pam_unix.so account required pam_unix.so
+1 -1
View File
@@ -64,7 +64,7 @@ As this role requires root-privileges, we added `become: true` to all tasks. So
- Description: Disable root-login. Set to `'without-password'` or `'yes'` to enable root-login - The quotes are required! - Description: Disable root-login. Set to `'without-password'` or `'yes'` to enable root-login - The quotes are required!
- `ssh_allow_tcp_forwarding` - `ssh_allow_tcp_forwarding`
- Default: `no` - Default: `no`
- Description: `'no'` to disable TCP Forwarding. Set to `'yes'` to allow TCP Forwarding. If you are using OpenSSH >= 6.2 version, you can specify `'yes'`, `'no'`, `'all'`, `'local'`or`'remote'`. <br> _Note_: values passed to this variable must be strings, thus values `'yes'`and`'no'` should be passed with quotes. - Description: `'no'` or `False` to disable TCP Forwarding. Set to `'yes'` or `True` to allow TCP Forwarding. If you are using OpenSSH >= 6.2 version, you can specify `'yes'`, `'no'`, `'all'`, `'local'`or`'remote'`.
- `ssh_gateway_ports` - `ssh_gateway_ports`
- Default: `false` - Default: `false`
- Description: `false` to disable binding forwarded ports to non-loopback addresses. Set to `true` to force binding on wildcard address. Set to `clientspecified` to allow the client to specify which address to bind to. - Description: `false` to disable binding forwarded ports to non-loopback addresses. Set to `true` to force binding on wildcard address. Set to `clientspecified` to allow the client to specify which address to bind to.
+2 -2
View File
@@ -5,9 +5,9 @@
name: 'os_vars' name: 'os_vars'
with_first_found: with_first_found:
- files: - files:
- '{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml' - '{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version | default() }}.yml'
- '{{ ansible_facts.distribution }}.yml' - '{{ ansible_facts.distribution }}.yml'
- '{{ ansible_facts.os_family }}_{{ ansible_facts.distribution_major_version }}.yml' - '{{ ansible_facts.os_family }}_{{ ansible_facts.distribution_major_version | default() }}.yml'
- '{{ ansible_facts.os_family }}.yml' - '{{ ansible_facts.os_family }}.yml'
skip: true skip: true
tags: always tags: always
+2 -1
View File
@@ -1,5 +1,6 @@
--- ---
- include_tasks: hardening.yml - name: Include hardening tasks
include_tasks: hardening.yml
args: args:
apply: apply:
become: true become: true
+1 -1
View File
@@ -24,7 +24,7 @@
# The following tasks only get executed when selinux is in state enforcing, # 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 # 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 # more info: https://github.com/hardening-io/ansible-ssh-hardening/issues/23
- name: run selinux tasks - name: Run selinux tasks
when: when:
- not (ssh_use_pam | bool) - not (ssh_use_pam | bool)
- ('ssh_password' not in ssh_password_module.stdout) - ('ssh_password' not in ssh_password_module.stdout)
@@ -106,10 +106,13 @@ RSAAuthentication yes
# Disable password-based authentication, it can allow for potentially easier brute-force attacks. # Disable password-based authentication, it can allow for potentially easier brute-force attacks.
PasswordAuthentication {{ 'yes' if ssh_client_password_login else 'no' }} PasswordAuthentication {{ 'yes' if ssh_client_password_login else 'no' }}
{# OpenBSD does not support GSSAPIAuthentication, so leave this out if on OpenBSD #}
{% if ansible_facts.os_family != 'OpenBSD' %}
# Only use GSSAPIAuthentication if implemented on the network. # Only use GSSAPIAuthentication if implemented on the network.
GSSAPIAuthentication {{ 'yes' if (ssh_gssapi_support|bool) else 'no' }} GSSAPIAuthentication {{ 'yes' if (ssh_gssapi_support|bool) else 'no' }}
GSSAPIDelegateCredentials {{ 'yes' if (ssh_gssapi_delegation|bool) else 'no' }} GSSAPIDelegateCredentials {{ 'yes' if (ssh_gssapi_delegation|bool) else 'no' }}
{% endif %}
# Disable tunneling # Disable tunneling
Tunnel no Tunnel no
@@ -143,10 +143,13 @@ KerberosTicketCleanup yes
#KerberosGetAFSToken no #KerberosGetAFSToken no
{% endif %} {% endif %}
{# OpenBSD does not support GSSAPIAuthentication, so leave this out if on OpenBSD #}
{% if ansible_facts.os_family != 'OpenBSD' -%}
# Only enable GSSAPI authentication if it is configured. # Only enable GSSAPI authentication if it is configured.
GSSAPIAuthentication {{ 'yes' if ssh_gssapi_support else 'no' }} GSSAPIAuthentication {{ 'yes' if ssh_gssapi_support else 'no' }}
GSSAPICleanupCredentials yes GSSAPICleanupCredentials yes
{% endif %}
{% if ssh_deny_users %} {% if ssh_deny_users %}
# In case you don't use PAM (`UsePAM no`), you can alternatively restrict users and groups here. # In case you don't use PAM (`UsePAM no`), you can alternatively restrict users and groups here.
# For key-based authentication this is not necessary, since all keys must be explicitely enabled. # For key-based authentication this is not necessary, since all keys must be explicitely enabled.
@@ -194,9 +197,9 @@ PermitTunnel {{ 'yes' if (ssh_permit_tunnel|bool) else 'no' }}
# Disable forwarding tcp connections. # Disable forwarding tcp connections.
# no real advantage without denied shell access # no real advantage without denied shell access
{% if sshd_version is version('6.2', '>=') %} {% if sshd_version is version('6.2', '>=') %}
AllowTcpForwarding {{ ssh_allow_tcp_forwarding if (ssh_allow_tcp_forwarding in ('yes', 'no', 'local', 'all', 'remote')) else 'no' }} AllowTcpForwarding {{ ssh_allow_tcp_forwarding if (ssh_allow_tcp_forwarding in ('yes', 'no', 'local', 'all', 'remote')) else ('yes' if (ssh_allow_tcp_forwarding|bool) else 'no') }}
{% else %} {% else %}
AllowTcpForwarding {{ ssh_allow_tcp_forwarding if (ssh_allow_tcp_forwarding in ('yes', 'no')) else 'no' }} AllowTcpForwarding {{ ssh_allow_tcp_forwarding if (ssh_allow_tcp_forwarding in ('yes', 'no')) else ('yes' if (ssh_allow_tcp_forwarding|bool) else 'no') }}
{% endif %} {% endif %}
# Disable agent forwarding, since local agent could be accessed through forwarded connection. # Disable agent forwarding, since local agent could be accessed through forwarded connection.