Execution
Date
08 Dec 2025 13:40:18 +0000
Duration
00:10:06.79
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.11
Summary
15
Hosts
608
Tasks
2412
Results
18
Plays
158
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-hardening/tasks/rhel7stig/sshd.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | --- # Copyright 2016, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Copy login warning banner ansible.builtin.copy: content: "{{ security_login_banner_text }}" dest: "{{ security_sshd_banner_file }}" owner: root group: root mode: "0644" tags: - high - sshd - V-71861 - V-72225 - name: Drop options from SSH config that we manage ansible.builtin.lineinfile: path: /etc/ssh/sshd_config state: absent regexp: "^{{ item.name }}\\s+(?!{{ item.value }})" validate: "/usr/sbin/sshd -T -f %s" with_items: "{{ sshd_settings_rhel7 | selectattr('enabled') }}" notify: - Restart ssh tags: - high - sshd - V-71939 - V-71957 - V-71959 - V-72221 - V-72225 - V-72237 - V-72241 - V-72245 - V-72247 - V-72249 - V-72243 - V-72243 - V-72303 - V-72251 - V-72253 - V-72265 - V-72267 - V-72261 - V-72263 - name: Adjust ssh server configuration based on STIG requirements ansible.builtin.blockinfile: dest: /etc/ssh/sshd_config state: present marker: "# {mark} MANAGED BY ANSIBLE-HARDENING" insertbefore: "BOF" validate: "/usr/sbin/sshd -T -f %s" block: |- {% set options = sshd_settings_rhel7 | selectattr('enabled') %} {% for option in options %} # {{ option['stig_id'] }} {{ option['name'] ~ ' ' ~ option['value'] }} {% endfor %} notify: - Restart ssh tags: - high - sshd - V-71939 - V-71957 - V-71959 - V-72221 - V-72225 - V-72237 - V-72241 - V-72245 - V-72247 - V-72249 - V-72243 - V-72243 - V-72303 - V-72251 - V-72253 - V-72265 - V-72267 - V-72261 - V-72263 - name: Ensure sshd is enabled at boot time ansible.builtin.service: name: "{{ ssh_service }}" enabled: true when: - security_enable_sshd | bool tags: - medium - sshd - V-72235 - name: Determine existing public ssh host keys ansible.builtin.shell: ls /etc/ssh/*.pub register: public_ssh_host_keys # The shell command will always report 'changed' so we need to # ignore that since this role is supposed to be idempotent. changed_when: false check_mode: false tags: - always - name: Public host key files must have mode 0644 or less ansible.builtin.file: path: "{{ item }}" mode: "u-xX,g-wxs,o-wxt" with_items: - "{{ public_ssh_host_keys.stdout_lines | default([]) }}" tags: - medium - sshd - V-72255 - name: Determine existing private ssh host keys ansible.builtin.shell: ls /etc/ssh/*_key register: private_ssh_host_keys # The shell command will always report 'changed' so we need to # ignore that since this role is supposed to be idempotent changed_when: false check_mode: false tags: - always - name: Private host key files must have mode 0600 or less ansible.builtin.file: path: "{{ item }}" mode: "u-xX,g-rwxs,o-rwxt" with_items: - "{{ private_ssh_host_keys.stdout_lines | default([]) }}" tags: - medium - sshd - V-72257 - name: Manage motd in pam.d ansible.builtin.replace: path: /etc/pam.d/sshd regexp: "^(#\\s)?(session\\s*optional\\s*pam_motd.so.*)$" replace: '{{ (security_sshd_dynamic_banner_disable | bool) | ternary("# \2", "\2") }}' when: security_sshd_dynamic_banner_disable | bool |