Adding ssh keys to authorized_keys
Event Information
Meaning
- This event indicates that someone has added an SSH key to the authorized_keys file, potentially granting them access to the system.
- It is important to investigate this event promptly to ensure that only authorized users have access to the cluster.
- To further investigate, you can check the authorized_keys file in the user’s home directory using the following command:
kubectl exec <pod_name> -- cat ~/.ssh/authorized_keys
Remediation
-
Create a Kubernetes ConfigMap containing the authorized_keys data:
-
Create a Kubernetes Pod manifest file to run a Python script using the Kubernetes API to add the SSH keys to authorized_keys:
-
Create a Python script (add_ssh_keys.py) to read the authorized_keys from the ConfigMap and add them to the appropriate authorized_keys file: