Repo Deployment Keys Rotated
More Info:
Deploy keys can have significant access to a repository and should be rotated on a regular basis.
Risk Level
Medium
Address
Security
Compliance Standards
Remediation
Using Console
To remediate the “Repo Deployment Keys Rotated” misconfiguration in GitHub using the GitHub console, you can follow the below steps:
- Login to your GitHub account and navigate to the repository where the deployment keys have been rotated.
- Click on the “Settings” tab on the right-hand side of the repository page.
- In the left-hand sidebar, click on the “Deploy Keys” option.
- Locate the deployment key that needs to be rotated and click on the “Delete” button next to it.
- Confirm the deletion by clicking on the “Delete” button in the pop-up window.
- Now, create a new deployment key by clicking on the “Add deploy key” button.
- Give a suitable title to the deployment key and paste the public key in the “Key” field.
- Check the “Allow write access” option if you want the key to have write access to the repository.
- Click on the “Add key” button to add the new deployment key to the repository.
- Finally, update the deployment key in your deployment pipeline or any other relevant services that use the key.
By following these steps, you can remediate the “Repo Deployment Keys Rotated” misconfiguration in GitHub using the GitHub console.
Using CLI
To remediate the misconfiguration of rotated deployment keys in a GitHub repository using the GitHub CLI, you can follow these steps:
-
Open a terminal or command prompt and ensure that you have the GitHub CLI installed on your system. If not, you can download it from the official website.
-
Log in to your GitHub account using the following command:
-
Select the appropriate authentication method and follow the prompts to complete the login process.
-
Navigate to the local copy of the repository in question using the
cd
command. -
Run the following command to remove the existing deployment keys:
Replace <key-name>
with the name of the key that needs to be removed.
- Generate a new deployment key using the following command:
Replace <key-name>
with a name for the new key, <title>
with a descriptive title for the key, and <path-to-public-key>
with the path to the public key file.
- Add the new deployment key to the repository using the following command:
Replace <key-name>
with the name of the new key.
- Verify that the new deployment key is added to the repository by running the following command:
This will display a list of all the deployment keys associated with the repository.
- Finally, update any relevant documentation or scripts to reflect the changes made.
By following these steps, you can remediate the misconfiguration of rotated deployment keys in a GitHub repository using the GitHub CLI.
Using Python
To remediate the misconfiguration of rotated deployment keys in a GitHub repository using Python, you can follow these steps:
- Generate a new deployment key for the repository using the
pygithub
library.
- Remove the old deployment key from the repository using the
pygithub
library.
- Update the deployment key in your deployment environment, such as your CI/CD pipeline, with the new key.
By following these steps, you can remediate the misconfiguration of rotated deployment keys in a GitHub repository using Python.