id: auth_ssh_password_authentication_disable
title: Disable Password Authentication for SSH
discussion: |
  If remote login through SSH is enabled, password based authentication _MUST_ be disabled for user login.

  All users _MUST_ go through multifactor authentication to prevent unauthenticated access and potential compromise to the system.

  NOTE: /etc/ssh/sshd_config will be automatically modified to its original state following any update or major upgrade to the operating system.
references:
  nist:
    cce:
      macos_27:
        - CCE-XXXXX-X
      macos_26:
        - CCE-95139-2
      macos_15:
        - CCE-94139-3
      macos_14:
        - CCE-92739-2
    800-53r5:
      - IA-2(1)
      - IA-2(2)
      - IA-2(6)
      - IA-2
      - IA-5(2)
      - MA-4
      - IA-2(8)
    800-171r3:
      - 03.05.01
      - 03.05.03
      - 03.05.04
      - 03.07.05
  disa:
    cci:
      - CCI-000186
      - CCI-000765
      - CCI-000766
      - CCI-000767
      - CCI-000768
      - CCI-000877
      - CCI-001941
      - CCI-001948
      - CCI-004046
    srg:
      - SRG-OS-000107-GPOS-00054
      - SRG-OS-000112-GPOS-00057
      - SRG-OS-000067-GPOS-00035
      - SRG-OS-000108-GPOS-00055
      - SRG-OS-000125-GPOS-00065
      - SRG-OS-000106-GPOS-00053
      - SRG-OS-000375-GPOS-00160
      - SRG-OS-000105-GPOS-00052
    disa_stig:
      macos_26:
        - APPL-26-001150
      macos_15:
        - APPL-15-001150
      macos_14:
        - APPL-14-001150
    cmmc:
      - IA.L1-3.5.1
      - IA.L1-3.5.2
      - IA.L2-3.5.3
      - IA.L2-3.5.4
      - MA.L2-3.7.5
  hhs:
    hicp:
      - 3.L.B
      - 6.L.B
  cis:
    controls_v8:
      - 6.3
      - 6.4
      - 6.5
platforms:
  macOS:
    '27.0': {}
    '26.0':
      benchmarks:
        - name: disa_stig
          severity: high
    '15.0':
      benchmarks:
        - name: disa_stig
          severity: high
    enforcement_info:
      check:
        shell: /usr/sbin/sshd -G | /usr/bin/grep -Ec '^(passwordauthentication\s+no|kbdinteractiveauthentication\s+no)'
        result:
          integer: 2
      fix:
        shell: |-
          include_dir=$(/usr/bin/awk '/^Include/ {print $2}' /etc/ssh/sshd_config | /usr/bin/tr -d '*')
          if [[ -z $include_dir ]]; then
            /usr/bin/sed -i.bk "1s/.*/Include \/etc\/ssh\/sshd_config.d\/\*/" /etc/ssh/sshd_config
          fi
          echo "passwordauthentication no" >> "${include_dir}01-mscp-sshd.conf"
          echo "kbdinteractiveauthentication no" >> "${include_dir}01-mscp-sshd.conf"

          for file in $(ls ${include_dir}); do
            if [[ "$file" == "100-macos.conf" ]]; then
                continue
            fi
            if [[ "$file" == "01-mscp-sshd.conf" ]]; then
                break
            fi
            /bin/mv ${include_dir}${file} ${include_dir}20-${file}
          done
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
ddm_info:
  declarationtype: com.apple.configuration.services.configuration-files
  service: com.apple.sshd
  config_file: sshd_config
  configuration_key: KbdInteractiveAuthentication
  configuration_value: false
