Ensure real-time clock is set to UTC
An XCCDF Rule
Description
Ensure that the system real-time clock (RTC) is set to Coordinated Universal Time (UTC).
Rationale
If time stamps are not consistently applied and there is no common time reference, it is difficult to perform forensic analysis. Time stamps generated by the operating system include date and time. Time is commonly expressed in UTC, a modern continuation of GMT, or local time with an offset from UTC.
- ID
- xccdf_org.ssgproject.content_rule_ensure_rtc_utc_configuration
- Severity
- High
- References
- Updated
Remediation - Ansible
- name: Check 'UTC' timezone is set
shell: |
set -o pipefail
timedatectl status | grep -i 'Time zone'| grep -iv 'UTC\|GMT' || true
register: check_tz
failed_when: check_tz.rc not in [ 0 , 1 ]
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
if timedatectl status | grep -i "time zone" | grep -iv 'UTC\|GMT'; then
timedatectl set-timezone UTC
fi