> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Ensure Admin Configuration File Ownership Is Root

### More Info:

Ensure that the admin.conf file ownership is set to root:root.

### Risk Level

Medium

### Address

Security

### Compliance Standards

* CIS Kubernetes

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Manual Steps" defaultOpen="true">
        1. On every control plane node, check the current ownership of the admin.conf file:
           ```bash theme={null}
           stat -c %U:%G /etc/kubernetes/admin.conf
           ```

        2. If the output is not `root:root`, change the ownership to root:root:
           ```bash theme={null}
           sudo chown root:root /etc/kubernetes/admin.conf
           ```

        3. (Optional but recommended) Ensure the file exists and is not world-writable:
           ```bash theme={null}
           ls -l /etc/kubernetes/admin.conf
           ```

        4. Verify the fix on every control plane node using the audit command:
           ```bash theme={null}
           /bin/sh -c 'if test -e /etc/kubernetes/admin.conf; then stat -c %U:%G /etc/kubernetes/admin.conf; fi'
           ```
           Confirm the output is:
           ```text theme={null}
           root:root
           ```
      </Accordion>

      <Accordion title="Using kubectl">
        kubectl cannot modify file ownership on control plane nodes, so it cannot be used to fix `/etc/kubernetes/admin.conf`. This change must be made directly on each control plane node’s filesystem; see the Manual Steps section for the exact commands to run there.
      </Accordion>

      <Accordion title="Automation">
        ```bash theme={null}
        #!/usr/bin/env bash
        #
        # Fix ownership of /etc/kubernetes/admin.conf to root:root
        # Scope: run on every control plane node
        # Safe to re-run (idempotent)

        set -euo pipefail

        ADMIN_CONF="/etc/kubernetes/admin.conf"

        echo "=== [CIS 1.1.14] Ensure admin.conf ownership is root:root ==="

        if [ ! -e "$ADMIN_CONF" ]; then
          echo "File not found: $ADMIN_CONF"
          echo "Nothing to do on this node."
          exit 0
        fi

        # Show current ownership
        current_owner="$(stat -c '%U:%G' "$ADMIN_CONF")"
        echo "Current ownership: $current_owner"

        # Apply fix if needed
        if [ "$current_owner" != "root:root" ]; then
          echo "Setting ownership to root:root on $ADMIN_CONF"
          chown root:root "$ADMIN_CONF"
        else
          echo "Ownership already correct; no change needed."
        fi

        # Verification (same as audit command)
        echo "Verifying ownership..."
        verify_owner="$(stat -c '%U:%G' "$ADMIN_CONF")"
        echo "Verified ownership: $verify_owner"

        if [ "$verify_owner" != "root:root" ]; then
          echo "ERROR: Ownership is still not root:root. Manual investigation required." >&2
          exit 1
        fi

        echo "=== Compliance OK on this node ==="
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

### Additional Reading:

* [https://kubernetes.io/docs/admin/kubeadm/](https://kubernetes.io/docs/admin/kubeadm/)
