Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restructure PAM handling and update for currently supported Linux distributions #392

Merged
merged 32 commits into from Mar 15, 2021

Conversation

schurzi
Copy link
Contributor

@schurzi schurzi commented Feb 8, 2021

The old handling of PAM was old and had some problems with current configurations.

This PR creates a completely new PAM configuration for RHEL distributions and adds faillock on RHEL and Debian. We still have no implementation for Arch and SuSE.

We now use a configuration that works with the automation tools from RedHat and the user can now run authconfigwithour disabling our changes. We also offer the possibiltiy of enabling sssd authentication, that should cover many usecases.

Testing is currently performed manually, since our CI does not contain testcases for PAM.

Test setup:

# RHEL distributions
yum install -y git openssh-server openssh-clients ansible

# Debian distributions
apt update
apt install -y git openssh-server openssh-client ansible

# all
mkdir -p ~/.ansible/collections/devsec/
cd ~/.ansible/collections/devsec/
git clone https://github.com/dev-sec/ansible-collection-hardening.git hardening
cd hardening
git checkout tally
ansible-galaxy collection install community.crypto

cat > test.yml <<EOF
---
- hosts: localhost
  collections:
    - devsec.hardening
  roles:
    - os_hardening
    - ssh_hardening
  vars:
    os_auth_retries: 2
    os_auth_lockout_time: 120
    ssh_permit_root_login: "yes"
    ssh_server_password_login: true
    ssh_client_password_login: true
    sshd_authenticationmethods: "password"
EOF

ansible-playbook test.yml

After applying these configuration we need to perform login tests via ssh and local login. These tests should cover root user and a normal user. We specially want to test lockout via faillock.

Tests performed:

  • CentOS 7
  • CentOS 8
  • Fedora
  • Amazon
  • Debian 9
  • Debian 10
  • Debian Sid
  • Ubuntu 16
  • Ubuntu 18
  • Ubuntu 20

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 8, 2021

fixes #377

@schurzi schurzi requested a review from rndmh3ro February 8, 2021 10:24
@schurzi
Copy link
Contributor Author

schurzi commented Feb 8, 2021

open: add faillock config for Debian based distros

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 13, 2021

fixes #273

@schurzi
Copy link
Contributor Author

schurzi commented Feb 13, 2021

fixes #252

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi schurzi changed the title remove deprecated pam_tally and use pam_faillock instead restructure PAM handling and update for current supported Linux distributions Feb 14, 2021
@schurzi schurzi changed the title restructure PAM handling and update for current supported Linux distributions restructure PAM handling and update for currently supported Linux distributions Feb 14, 2021
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi schurzi marked this pull request as ready for review February 14, 2021 23:20
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 14, 2021

mabe this warants a major version increase?

@schurzi
Copy link
Contributor Author

schurzi commented Feb 14, 2021

fixes #278

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 16, 2021

tested with current Fedora 33, it should work starting from Fedora 28 possibly earlier. But Ansible in this versions is no longer compatible with Collections. So I suppose this is ok.

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Feb 16, 2021

@rndmh3ro I think we should proceed. I tested Logins in various forms and everything seems in order. Upgrading also works for Debian and in RHEL based disrtos.

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
@schurzi
Copy link
Contributor Author

schurzi commented Mar 15, 2021

now also tested the role update from previous version on centos7 and centos8

@schurzi schurzi merged commit 74c7294 into master Mar 15, 2021
@schurzi schurzi deleted the tally branch March 15, 2021 23:10
divialth pushed a commit to divialth/ansible-collection-hardening that referenced this pull request Aug 3, 2022
restructure PAM handling and update for currently supported Linux distributions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants