Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of not having Just-In-Time (JIT) access enabled for virtual machines in Azure, you can follow the below steps using Azure Portal:
  1. Log in to the Azure Portal (https://portal.azure.com/).
  2. Navigate to the virtual machine for which you want to enable JIT access.
  3. From the left-hand side menu, select “Security + networking”.
  4. Under the “Security” section, select “Just-in-time VM access”.
  5. On the Just-in-time VM access page, click on “Enable JIT on VM”.
  6. In the “Basic settings” section, select the “On” radio button to enable JIT access.
  7. In the “Advanced settings” section, configure the following settings:
    • Maximum JIT access time: Set the maximum time for which the JIT access request will be valid.
    • Ports: Select the ports that you want to open for JIT access.
    • IP address: Select the IP address range from which you want to allow JIT access.
  8. Click on the “Review + create” button to review the JIT access settings.
  9. Once you have reviewed the settings, click on the “Create” button to enable JIT access for the virtual machine.
Once JIT access is enabled, users can request access to the virtual machine by clicking on the “Request access” button on the Just-in-time VM access page. The request will be reviewed and approved by an authorized user before access is granted.

To enable Just-In-Time (JIT) Access for Virtual Machines in Azure using Azure CLI, follow these steps:
  1. Open the Azure CLI in your preferred terminal or command prompt.
  2. Run the following command to enable JIT access for the virtual machine:
Note: Replace <resource-group-name> with the name of your resource group and <vm-name> with the name of your virtual machine.
  1. After running the command, you will receive a JSON output containing the updated information about your virtual machine.
  2. Verify that JIT access has been enabled for the virtual machine by going to the Azure portal and checking the virtual machine’s “Security” settings. You should see “JIT VM access” enabled for the virtual machine.
That’s it! JIT access has now been enabled for your virtual machine in Azure using Azure CLI.
To remediate the misconfiguration “Enable Just-In-Time Access for Virtual Machines” in AZURE using Python, you can follow the below steps:
  1. Import the required libraries:
  1. Authenticate and create the client object:
  1. Get the resource group and virtual machine name:
  1. Get the virtual machine object:
  1. Create the JIT access policy object:
  1. Add the JIT access policy to the virtual machine network security group:
  1. Save the changes:
This will enable JIT access for the virtual machine in Azure.
This change does not force replacement of the existing virtual machine; it adds a separate Security Center JIT policy resource that governs on-demand access to the VM’s network ports.For verification, terraform plan should show creation of azurerm_security_center_just_in_time_network_access_policy.VM_JIT with the specified virtual_machines/ports configuration and no changes requiring replacement of azurerm_linux_virtual_machine.VM.