Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Serial Ports Connection Should Be Disabled” for GCP using GCP console, you can follow the below steps:
- Login to the GCP console.
- Select the project in which you want to remediate the misconfiguration.
- Click on the “Compute Engine” option from the left-hand side menu.
- Select the instance for which you want to disable the serial port connection.
- Click on the “Edit” button at the top of the page.
- Scroll down to the “Cloud API access scopes” section.
- In the “Cloud API access scopes” section, click on the “Allow full access to all Cloud APIs” option to expand it.
- Uncheck the “Enable connecting to serial ports” option.
- Click on the “Save” button at the bottom of the page to apply the changes.
- Once the changes are applied, the serial port connection will be disabled for the selected instance.
Using CLI
Using CLI
To remediate the misconfiguration of serial ports connection being enabled in GCP using GCP CLI, you can follow the below steps:
- Open the Cloud Shell in the GCP Console.
- Run the following command to list all the instances in your project:
- Choose the instance for which you want to disable serial port connection.
- Run the following command to disable serial port connection for the chosen instance:
Replace [INSTANCE_NAME] with the name of the instance you want to remediate.
- Verify that the serial port connection is disabled for the instance by running the following command:
This command should not return any output.
Using Python
Using Python
To remediate the “Serial Ports Connection Should Be Disabled” misconfiguration for GCP using Python, you can use the Cloud Asset Inventory and Cloud Asset API to identify and disable serial ports connections on all Compute Engine instances in your project. Here are the step-by-step instructions:
- First, you need to enable the Cloud Asset API for your project. You can do this by going to the Google Cloud Console, selecting your project, and navigating to APIs & Services > Dashboard. Then, click on the ”+ ENABLE APIS AND SERVICES” button, search for “Cloud Asset API”, and click on the “ENABLE” button.
- Next, you need to install the Google Cloud SDK and the Python client library for the Cloud Asset API. You can do this by running the following command in your terminal:
- Once you have installed the necessary tools, you can use the following Python code to identify and disable serial ports connections on all Compute Engine instances in your project:
- Replace “YOUR_PROJECT_ID” with your actual GCP project ID in the code.
- Run the code in your terminal or in a Python IDE.