This page describes how to access user VMs from a host with a VPN tunnel connection.

Hosts in the remote network with a VPN tunnel connection to a
GDC organization can access the primary interface of
organization user VMs, assuming egress and ingress traffic to the project containing the
user VM is allowed.

## Before you begin

To configure ingress and egress traffic for a VPN tunnel, you must have the following:

- An existing VPN tunnel. For more information, see [Create a VPN tunnel](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/vpn/configure-the-tunnel.md.txt).
- Have enabled egress and ingress traffic to the project containing the VM. For more information, see [Control ingress and egress traffic](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/vpn/egress-and-ingress.md.txt).
- The necessary identity and access roles:

  - VPN Admin: has read and write permissions on all VPN-related resources. Ask your IAM Org Admin to grant you the VPN Admin (`vpn-admin`) role.
  - VPN Viewer: has read permissions on all VPN-related resources. Ask your IAM Org Admin to grant you the VPN Viewer (`vpn-viewer`) role.
  - Virtual Machine Project Admin: manages VMs in the project namespace. Ask your IAM Org Admin to grant you the Virtual Machine Project Admin (`project-vm-admin`) role.
  - For more information, see [Role definitions](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/iam/role-definitions).

## Access the user VM

Follow these steps to access the primary interface of the user VM:

1. Get the interfaces of the user VM by viewing its respective `VirtualMachine` object
   in the org admin cluster:

   ```bash
   kubectl --kubeconfig MANAGEMENT_API_SERVER get -n PROJECT_NAME gvm VM_NAME -ojson | jq '.status.network.interfaces'
   ```

   Replace the following:
   - `MANAGEMENT_API_SERVER`: the zonal API server's kubeconfig path. If you have not yet generated a kubeconfig file for the API server in your targeted zone, see [Sign in](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/platform/pa-user/iam/sign-in.md.txt#cli) for details.
   - `VM_NAME`: the name of the `VirtualMachine` object.

   The output looks like the following example:

         [
           {
             "ipAddresses": [
               "172.16.19.189"
             ],
             "macAddress": "8a:fc:81:0b:41:dc",
             "name": "net1"
           }
         ]
         ```

2. Hosts in the remote network with a VPN tunnel connection to a GDC organization
   can access user VMs through the primary `net1` interface:

   ```bash
   /home/ubuntu# ssh -i ~/vm-access user@172.16.19.189
   ```

   Note, for SSH access details including retrieving a key for a VM, see [Connect
   to a VM](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/gdcag/application/ao-user/vms/connect-to-vm/connect-to-a-vm).