Skip to main content

๐Ÿ›ก๏ธ AWS IAM SSH Public Key are not rotated every 90 days or less๐ŸŸข

  • Contextual name: ๐Ÿ›ก๏ธ SSH Public Key are not rotated every 90 days or less๐ŸŸข
  • ID: /ce/ca/aws/iam/ssh-public-keys-are-not-rotated-every-90-days
  • Tags:
  • Policy Type: COMPLIANCE_POLICY
  • Policy Categories: SECURITY

Logicโ€‹

Similar Policiesโ€‹

Descriptionโ€‹

Open File

Descriptionโ€‹

Identify AWS IAM SSH public keys that have been active for more than 90 days without rotation.

Ensure that all IAM SSH public keys are rotated at least every 90 days to reduce the risk of accidental exposure and to protect AWS CodeCommit repositories from unauthorized access.

Rationaleโ€‹

IAM SSH public keys are used to authenticate users for programmatic access to services such as AWS CodeCommit. Similar to passwords and access keys, these credentials should be rotated regularly. Regular key rotation limits the amount of time a compromised key can be used to access source code repositories.

Auditโ€‹

This policy flags an AWS IAM SSH Public Key as INCOMPLIANT if the Upload Date is older than 90 days.

An AWS IAM SSH Public Key is marked as INAPPLICABLE if its Status is not set to Active.

Remediationโ€‹

Open File

Remediationโ€‹

Rotate IAM SSH Public Keyโ€‹

Rotate IAM SSH public keys that have exceeded the recommended rotation period by creating a new key, updating dependent configurations, and removing the outdated key.

From Command Lineโ€‹
  1. Generate and upload a new SSH public key

    Run the upload-ssh-public-key command to upload the new SSH public key (PEM or SSH-RSA format) for the specified IAM user:

    aws iam upload-ssh-public-key \
    --region {{region}} \
    --user-name {{user-name}} \
    --ssh-public-key-body file://{{sshkey.pub}}
    --query SSHPublicKey.SSHPublicKeyId

    Note the SSH Public Key ID returned by this command. It will be required in subsequent steps.

  2. Update AWS CodeCommit SSH configuration

    Replace the existing SSH Key ID in your CodeCommit SSH configuration with the newly generated key ID, then validate access to your repositories.

    Example configuration:

    Host git-codecommit.*.amazonaws.com
    User {{ssh-key-id}}
    IdentityFile {{private-key-file}}

... see more

policy.yamlโ€‹

Open File

Linked Framework Sectionsโ€‹

SectionSub SectionsInternal RulesPoliciesFlagsCompliance
๐Ÿ’ผ AWS Well-Architected โ†’ ๐Ÿ’ผ SEC02-BP02 Use temporary credentials1no data
๐Ÿ’ผ Cloudaware Framework โ†’ ๐Ÿ’ผ Credential Lifecycle Management23no data