|
76 | 76 | #
|
77 | 77 | # Restrict cron permissions. All jobs are owned by root so there's no
|
78 | 78 | # reason to allow others any level of access. This is also necessary to
|
79 |
| -# satisfy external auditing of CIS security benchmarks. |
| 79 | +# satisfy external auditing of CIS security benchmarks. Also ensuring |
| 80 | +# the permissions on /etc/ssh/sshd_config are configured. |
80 | 81 | #
|
81 | 82 | - file:
|
82 |
| - path: /etc/crontab |
| 83 | + path: "{{ item }}" |
83 | 84 | state: file
|
84 | 85 | mode: 0600
|
| 86 | + with_items: |
| 87 | + - /etc/crontab |
| 88 | + - /etc/ssh/sshd_config |
85 | 89 |
|
86 | 90 | - file:
|
87 | 91 | path: "{{ item }}"
|
|
228 | 232 | - 'delphix'
|
229 | 233 | - 'root'
|
230 | 234 |
|
231 |
| -- lineinfile: |
232 |
| - path: /etc/ssh/sshd_config |
233 |
| - regexp: "^#?{{ item.key }} " |
234 |
| - line: "{{ item.key }} {{ item.value }}" |
235 |
| - with_items: |
236 |
| - # |
237 |
| - # Configure SSH to allow PAM "conversations" (interactions with the user). |
238 |
| - # |
239 |
| - - { key: "ChallengeResponseAuthentication", value: "yes" } |
240 |
| - # |
241 |
| - # Harden the appliance by disabling ssh-agent(1), tcp, UNIX domain, and |
242 |
| - # X11 forwarding. Note that this doesn't improve security unless users are |
243 |
| - # also denied shell access. |
244 |
| - # |
245 |
| - - { key: "AllowAgentForwarding", value: "no" } |
246 |
| - - { key: "AllowStreamLocalForwarding", value: "no" } |
247 |
| - - { key: "AllowTcpForwarding", value: "no" } |
248 |
| - - { key: "X11Forwarding", value: "no" } |
249 |
| - |
250 | 235 | #
|
251 |
| -# The CRA project mandated a 30 minute timeout for any idle connections. |
252 |
| -# By enabling an inactivity timeout we ensure that idle connections are |
253 |
| -# closed. Thus any sessions that are accidentally left opened at a |
254 |
| -# customer site will timeout preventing customers from gaining access to |
255 |
| -# our engine. |
| 236 | +# The 'ClientAliveInterval' setting determines the amount of time |
| 237 | +# (in seconds) the sshd server will wait to receive data from the |
| 238 | +# client before sending a request for response. |
256 | 239 | #
|
257 | 240 | - set_fact:
|
258 |
| - ssh_client_alive_interval: "1800" |
| 241 | + ssh_client_alive_interval: "300" |
| 242 | + ssh_client_alive_count_max: "3" |
259 | 243 |
|
260 | 244 | #
|
261 | 245 | # With that said (see comment above), the Azure marketplace does not
|
|
264 | 248 | #
|
265 | 249 | - set_fact:
|
266 | 250 | ssh_client_alive_interval: "180"
|
267 |
| - when: platform == "azure" |
| 251 | + ssh_client_alive_count_max: "0" |
| 252 | + when: |
| 253 | + - platform == "azure" |
268 | 254 |
|
269 | 255 | - lineinfile:
|
270 | 256 | path: /etc/ssh/sshd_config
|
271 | 257 | regexp: "^#?{{ item.key }} "
|
272 | 258 | line: "{{ item.key }} {{ item.value }}"
|
273 | 259 | with_items:
|
274 |
| - - { key: "ClientAliveInterval", value: "{{ ssh_client_alive_interval }}" } |
275 |
| - - { key: "ClientAliveCountMax", value: "0" } |
276 |
| - when: |
277 | 260 | #
|
278 |
| - # For developer convenience, we only enable the CRA mandated timeout |
279 |
| - # for external variants. The idle timeout can be a burden when we |
280 |
| - # need to run long running processes over SSH on our internal |
281 |
| - # systems (e.g. for development, testing, etc). |
| 261 | + # Configure SSH to allow PAM "conversations" (interactions with the user). |
282 | 262 | #
|
283 |
| - - variant is regex("external-.*") |
| 263 | + - { key: "ChallengeResponseAuthentication", value: "yes" } |
| 264 | + # |
| 265 | + # Harden the appliance by disabling ssh-agent(1), tcp, UNIX domain, and |
| 266 | + # X11 forwarding. Note that this doesn't improve security unless users are |
| 267 | + # also denied shell access. |
| 268 | + # |
| 269 | + - { key: "AllowAgentForwarding", value: "no" } |
| 270 | + - { key: "AllowStreamLocalForwarding", value: "no" } |
| 271 | + - { key: "AllowTcpForwarding", value: "no" } |
| 272 | + - { key: "Ciphers", value: "[email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]" } |
| 273 | + - { key: "ClientAliveCountMax", value: "{{ ssh_client_alive_count_max }}" } |
| 274 | + - { key: "ClientAliveInterval", value: "{{ ssh_client_alive_interval }}" } |
| 275 | + - { key: "HostKeyAlgorithms", value: "-ssh-rsa*" } |
| 276 | + - { key: "KexAlgorithms", value: "curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256"} |
| 277 | + - { key: "LoginGraceTime", value: "60"} |
| 278 | + |
| 279 | + - { key: "MaxAuthTries", value: "4" } |
| 280 | + - { key: "MaxStartups", value: "10:30:60"} |
| 281 | + - { key: "PermitRootLogin", value: "no" } |
| 282 | + - { key: "X11Forwarding", value: "no" } |
| 283 | + notify: "sshd config changed" |
284 | 284 |
|
285 | 285 | - blockinfile:
|
286 | 286 | path: /etc/profile
|
|
300 | 300 | #
|
301 | 301 | - variant is regex("external-.*")
|
302 | 302 | #
|
303 |
| -# Harden the appliance by disabling SFTP. |
| 303 | +# Harden the appliance by disabling SFTP on external variants. |
304 | 304 | #
|
305 | 305 | - replace:
|
306 | 306 | path: /etc/ssh/sshd_config
|
307 | 307 | regexp: '^(Subsystem.*sftp.*)'
|
308 | 308 | replace: '#\1'
|
| 309 | + when: |
| 310 | + # |
| 311 | + # Disable sftp on external variants and leave it enabled on internal |
| 312 | + # variants for developer convenience and to facilitate test automation. |
| 313 | + # |
| 314 | + - variant is regex("external-.*") |
309 | 315 |
|
310 | 316 | #
|
311 | 317 | # Ssh leads to the CLI, not bash, so let's remove all the linuxy shell goodies,
|
|
322 | 328 | replace: '#\1'
|
323 | 329 |
|
324 | 330 | #
|
325 |
| -# Prevent sshd from offering weak message authentication codes to clients. |
| 331 | +# Restrict su access to users that are part of the root group (gid 0). |
| 332 | +# On a Delphix engine, this is restricted to the delphix user. |
326 | 333 | #
|
327 |
| -# The "MACs" configuration parameter in sshd_config takes a list of algorithms |
328 |
| -# as its parameter. This list may be prefixed by a '+' or '-' operator |
329 |
| -# (indicating that the given list should be appended to or removed from the |
330 |
| -# existing MAC set, respectively), or neither operator (indicating that the |
331 |
| -# given list should replace the existing MAC set). If there already exists a |
332 |
| -# "MACs -..." line, we can append to this list. If otherwise, we need to add |
333 |
| -# this as a separate line in the configuration. |
334 |
| -# |
335 |
| -- shell: grep -c -E "^MACs(\s+)-" /etc/ssh/sshd_config || true |
336 |
| - register: grep_sshd_config_macs_to_remove |
337 |
| - |
338 |
| -- shell: grep -c -E "^MACs(\s+)-(.*)hmac-sha1\*,umac-64\*" /etc/ssh/sshd_config || true |
339 |
| - register: grep_sshd_config_macs_already_removed |
340 |
| - |
341 |
| -- lineinfile: |
342 |
| - path: /etc/ssh/sshd_config |
343 |
| - backrefs: yes |
344 |
| - regexp: '^MACs[\s]+-(.*)$' |
345 |
| - line: 'MACs -\1,hmac-sha1*,umac-64*' |
346 |
| - notify: "sshd config changed" |
347 |
| - when: grep_sshd_config_macs_to_remove.stdout != "0" and grep_sshd_config_macs_already_removed == "0" |
348 |
| - |
349 |
| -- lineinfile: |
350 |
| - path: /etc/ssh/sshd_config |
351 |
| - insertafter: EOF |
352 |
| - line: "MACs -hmac-sha1*,umac-64*" |
353 |
| - notify: "sshd config changed" |
354 |
| - when: grep_sshd_config_macs_to_remove.stdout == "0" |
| 334 | +- replace: |
| 335 | + dest: /etc/pam.d/su |
| 336 | + regexp: '^#?[\s]*(auth[\s]+required[\s]+pam_wheel\.so.*)$' |
| 337 | + replace: '\1' |
355 | 338 |
|
356 | 339 | #
|
357 | 340 | # Enable SNMP client tools to load MIBs by default.
|
|
681 | 664 | when:
|
682 | 665 | - variant == "internal-buildserver"
|
683 | 666 | - not ansible_is_chroot
|
| 667 | + |
| 668 | +- name: Add systemctl bash completion |
| 669 | + copy: |
| 670 | + dest: "/etc/bash_completion.d/systemctl" |
| 671 | + content: | |
| 672 | + if [[ -r /usr/share/bash-completion/completions/systemctl ]]; then |
| 673 | + . /usr/share/bash-completion/completions/systemctl && complete -F _systemctl systemctl |
| 674 | + fi |
| 675 | +
|
| 676 | +- name: Source bash completion |
| 677 | + blockinfile: |
| 678 | + dest: "/export/home/delphix/.bashrc" |
| 679 | + block: | |
| 680 | + . /etc/bash_completion.d/systemctl |
| 681 | + . /etc/bash_completion.d/zfs |
| 682 | + PATH=$PATH:/opt/delphix/server/bin |
| 683 | +
|
| 684 | +# |
| 685 | +# CIS: Set default umask (DLPX-87205) |
| 686 | +# We need to set default umask as 027 in the /etc/bash.bashrc file, |
| 687 | +# so that the same can be applied for all the users on the engine. |
| 688 | +# |
| 689 | +- blockinfile: |
| 690 | + path: /etc/bash.bashrc |
| 691 | + block: | |
| 692 | + # Set default umask value. |
| 693 | + umask 027 |
0 commit comments