diff --git a/roles/os_hardening/README.md b/roles/os_hardening/README.md index 0453be8c..12e5f919 100644 --- a/roles/os_hardening/README.md +++ b/roles/os_hardening/README.md @@ -250,6 +250,9 @@ We know that this is the case on Raspberry Pi. - `os_profile_enabled` - Default: `true` - Description: Set to false to disable installing and configuring profile. +- `os_security_auto_logout` + - Default: `0` + - Description: Set timeout in seconds for logout users automatically after time. Setting this to `0` disables the timeout. - `os_securetty_enabled` - Default: `true` - Description: Set to false to disable installing and configuring securetty. diff --git a/roles/os_hardening/defaults/main.yml b/roles/os_hardening/defaults/main.yml index 1d6c893f..0a96c8a7 100644 --- a/roles/os_hardening/defaults/main.yml +++ b/roles/os_hardening/defaults/main.yml @@ -364,6 +364,9 @@ os_profile_enabled: true # Set to false to disable installing and configuring securetty. os_securetty_enabled: true +# Set timeout in seconds for logout users automatically after time. Setting this to `0` disables the timeout. +os_security_auto_logout: 0 + # Set to false to disable installing and configuring sysctl. os_sysctl_enabled: true diff --git a/roles/os_hardening/tasks/profile.yml b/roles/os_hardening/tasks/profile.yml index 00e2b1ff..e4e3b831 100644 --- a/roles/os_hardening/tasks/profile.yml +++ b/roles/os_hardening/tasks/profile.yml @@ -13,3 +13,11 @@ path: /etc/profile.d/pinerolo_profile.sh state: absent when: os_security_kernel_enable_core_dump | bool + +- name: Add autologout to profile env + template: + src: 'etc/profile.d/tmout.sh.j2' + dest: '/etc/profile.d/tmout.sh' + owner: 'root' + group: 'root' + mode: '0750' diff --git a/roles/os_hardening/templates/etc/profile.d/tmout.sh.j2 b/roles/os_hardening/templates/etc/profile.d/tmout.sh.j2 new file mode 100644 index 00000000..2b59d50c --- /dev/null +++ b/roles/os_hardening/templates/etc/profile.d/tmout.sh.j2 @@ -0,0 +1,3 @@ +# Logout Timeout +export TMOUT={{ os_security_auto_logout }} +readonly TMOUT