Connect to Linux VMs using Cloud VPN or Cloud Interconnect Stay organized with collections Save and categorize content based on your preferences.
This document describes how to connect to a virtual machine (VM) instancethrough its internal IP address, from an on-premises network that usesCloud VPN orCloud Interconnectto connect to the VM's VPC network.
Connecting to a VM using its internal IP address is useful if the VM doesn'thave an external IP address. If the VM does have an external IP address,connect to the VM using its external IP address.If your on-premises network isn't connected to your VM's VPCnetwork and you need to connect to your VM's internal IP address, review theother methods listed inConnection options for internal-only VMs.
Supported operating systems
These connection methods are supported for allpublic Linux images that are available onCompute Engine. For Fedora CoreOS images, you mustset up SSH access before you can use these methods.
Connect to VMs
To connect to a VM, complete the steps in one of the following tabs.
gcloud
Connect to a VM using SSH by running thegcloud compute ssh command with the--internal-ip flag:
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Connect to the VM by running the following command:
gcloud compute sshVM-NAME \ --internal-ip
ReplaceVM_NAME with the name of the VM that you want to connect to.
IAP Desktop
To connect to a VM using IAP Desktop, do the following:
Install IAP Desktop on your workstation if you haven't already.
Open IAP Desktop. TheAdd projects window opens.
When prompted, sign in using the Google account that has access to the project with the VMs you want to connect to.
In theAdd projects window, enter the project ID or name of the project that contains the VMs you want to connect to.
In theProject Explorer window, right-click the name of the VM that you want to connect to and selectConnection settings.
In theConnection settings window, setConnect via toVpc.
In theProject Explorer window, right-click the name of the VM again and selectConnect to connect to the VM.
OpenSSH clients
Connect through a VM's internal IP address from an OpenSSH client, by doing the following:
- Add an SSH key to the VM if you haven't already.
In the Google Cloud console, go to theVM Instances page and find the internal IP address of the VM that you want to connect to.
- Open a terminal on your workstation.
Connect to the VM by running the following command:
ssh -iPATH_TO_PRIVATE_KEYUSERNAME@INTERNAL_IP
Replace the following:
PATH_TO_PRIVATE_KEY: the path to the private SSH key file that corresponds to the public key you added to the VM.USERNAME: your username. If you manage your SSH keys in metadata, the username is what you specified when youcreated the SSH key. For OS Login accounts, the username isdefined in your Google profile. For example,cloudysanfrancisco_example_comorcloudysanfrancisco.INTERNAL_IP: the internal IP address of the VM.
PuTTY app
Connect through a VM's internal IP address using PuTTY, by doing the following:
- Add an SSH key to the VM if you haven't already.
- If your workstation doesn't already have the PuTTY app installed,download the PuTTY package files.
In the Google Cloud console, go to theVM Instances page and find the internal IP address of the VM that you want to connect to.
- Open the PuTTY app. A connection configuration window opens.
In the
Host Namefield, enter the username associated with the SSH key, and the internal IP address of the VM that you want to connect to. Use the following format:USERNAME@INTERNAL_IP
Replace the following:
USERNAME: your username. If you manage your SSH keys in metadata, the username is what you specified when youcreated the SSH key. For OS Login accounts, the username isdefined in your Google profile. For example,cloudysanfrancisco_example_comorcloudysanfrancisco.INTERNAL_IP: the internal IP address of the VM.
- In theCategory menu, navigate toConnection > SSH > Auth.
- In thePrivate key file for authentication field, select the private SSH key file that corresponds to the public key you added to the VM.
- ClickOpen to connect to the VM.
Troubleshooting
To find methods for diagnosing and resolving failed SSH connections, seeTroubleshooting SSH.
What's next
- Learn how tomanage access to VMs.
- Learn how totransfer files to VMs.
- Learn howSSH connections to Linux VMswork on Compute Engine.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.