id: system_settings_ssh_disable
title: Disable SSH Server for Remote Access Sessions
discussion: |
  SSH service _MUST_ be disabled for remote access.
references:
  nist:
    cce:
      macos_27:
        - CCE-XXXXX-X
      macos_26:
        - CCE-95406-5
      macos_15:
        - CCE-94399-3
      macos_14:
        - CCE-92994-3
    800-53r5:
      - CM-7
      - CM-7(1)
      - AC-17
    800-171r3:
      - 03.01.02
      - 03.04.06
  disa:
    cmmc:
      - AC.L1-3.1.1
      - CM.L2-3.4.6
      - CM.L2-3.4.7
  bzk:
    bio:
      - 8.27
      - 8.27.01
  hhs:
    hicp:
      - 6.L.A
  cis:
    benchmark:
      macos_26:
        - 2.3.3.4 (level 1)
      macos_15:
        - 2.3.3.4 (level 1)
      macos_14:
        - 2.3.3.4 (level 1)
    controls_v8:
      - 4.1
      - 4.8
platforms:
  macOS:
    '27.0': {}
    '26.0':
      benchmarks:
        - name: cis_lvl1
        - name: cis_lvl2
        - name: nlmapgov_plus
    '15.0':
      benchmarks:
        - name: cis_lvl1
        - name: cis_lvl2
        - name: nlmapgov_plus
      enforcement_info:
        check:
          shell: /bin/launchctl print-disabled system | /usr/bin/grep -c '"com.openssh.sshd" => disabled'
          result:
            integer: 1
    enforcement_info:
      check:
        shell: |-
          result="FAIL"
          enabled=$(/bin/launchctl print-disabled system | /usr/bin/grep '"com.openssh.sshd" => enabled')
          running=$(/bin/launchctl print system/com.openssh.sshd 2>/dev/null)

          if [[ -z "$running" ]] && [[ -z "$enabled" ]]; then
            result="PASS"
          elif [[ -n "$running" ]]; then
            result="${result}  RUNNING"
          elif [[ -n "$enabled" ]]; then
            result="${result}  ENABLED"
          fi
          echo $result
        result:
          string: PASS
      fix:
        shell: |-
          /usr/sbin/systemsetup -f -setremotelogin off >/dev/null
          /bin/launchctl disable system/com.openssh.sshd
        additional_info: 'NOTE: Systemsetup with -setremotelogin flag will fail unless you grant Full Disk Access to systemsetup or its parent process. Requires supervision.'
tags:
  - 800-53r5_low
  - 800-53r5_moderate
  - 800-53r5_high
  - 800-171
  - cisv8
  - cnssi-1253_low
  - cnssi-1253_high
  - cmmc_lvl2
  - cmmc_lvl1
  - cnssi-1253_moderate
  - hicp_lp
