Stay organized with collections Save and categorize content based on your preferences.
Linux
This document describes how to connect to Linux virtual machine (VM) instances that have external IP addresses by using SSH keys. To learn how to connect to VMs that don't have external IP addresses, see Connection options for internal-only VMs. To learn how to connect to Linux VMs using SSH certificates, see Require SSH certificates for OS Login VMs.
For information about how SSH connections work in Compute Engine, including SSH key configuration and storage, see SSH connections to Linux VMs.
Note: When a user connects to a VM, that user can use all of the IAM permissions granted to the service account attached to the VM. Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.These connection methods are supported for all public Linux images that are available on Compute Engine. For Fedora CoreOS images, you must set up SSH access before you can use these methods.
Connect to VMsTo connect to a VM, complete the steps in one of the following tabs.
ConsoleConnect to VMs using SSH-in-browser from the Google Cloud console, by doing the following:
Connect to a VM using SSH by running the gcloud compute ssh
command:
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud 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.
Run the following command:
gcloud compute ssh --project=PROJECT_ID --zone=ZONE VM_NAME
Replace the following:
PROJECT_ID
: the ID of the project that contains the VMZONE
: the name of the zone that the VM is located inVM_NAME
: the name of the VMIf you have set default properties for the Google Cloud CLI, you can omit the --project
and --zone
flags from this command. For example:
gcloud compute ssh VM_NAME
Connect to a VM using SSH from an OpenSSH client, do the following:
In the Google Cloud console, go to the VM Instances page and find the external IP address of the VM that you want to connect to.
Connect to the VM by running the following command:
ssh -i PATH_TO_PRIVATE_KEY USERNAME@EXTERNAL_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 you created the SSH key. For OS Login accounts, the username is defined in your Google profile. For example, cloudysanfrancisco_example_com
or cloudysanfrancisco
.EXTERNAL_IP
: the external IP address of the VM.Connect to a VM using SSH from the Windows PuTTY app, by doing the following:
In the Google Cloud console, go to the VM Instances page and find the external IP address of the VM that you want to connect to.
In the Host Name
field, enter the username associated with the SSH key, and the external IP address of the VM that you want to connect to. Use the following format:
USERNAME@EXTERNAL_IP
Replace the following:
USERNAME
: your username. If you manage your SSH keys in metadata, the username is what you specified when you created the SSH key. For OS Login accounts, the username is defined in your Google profile. For example, cloudysanfrancisco_example_com
or cloudysanfrancisco
.EXTERNAL_IP
: the external IP address of the VM.To connect to a VM using SSH from the Secure Shell Chrome app, do the following:
Add an SSH key to the VM if you haven't already.
Install Secure Shell on your Chromebook or Chrome browser if you have not done so already.
In the Google Cloud console, go to the VM Instances page and find the external IP address of the VM that you want to connect to.
Open the Secure Shell in a Chrome browser tab address bar, by doing the following:
ssh
.Space
.Enter
.Click [New Connection].
In the username field, enter your username. If you manage your SSH keys in metadata, the username is what you specified when you created the SSH key. For OS Login accounts, the username is defined in your Google profile. For example, cloudysanfrancisco_example_com
or cloudysanfrancisco
.
In the hostname field, enter the external IP address of the VM.
In the Identity field, click Import... and select the path to the private SSH key file that corresponds to the public key you added to the VM.
Click [ENTER] Connect to connect to the VM.
To find methods for diagnosing and resolving failed SSH connections, see Troubleshooting SSH.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document guides users on connecting to Linux virtual machine (VM) instances with external IP addresses, detailing how to connect to VMs that do not have external IP's through the provided link."],["Compute Engine offers various methods to connect to Linux VMs, including using the Google Cloud console, gcloud CLI, OpenSSH client, PuTTY app, and Secure Shell Chrome app."],["Before connecting, users should set up authentication and can install the Google Cloud CLI and set a default region and zone."],["SSH key management is essential for connecting to VMs, with options to create ephemeral or persistent keys, and users can add SSH keys to VMs as needed."],["Supported operating systems include all public Linux images on Compute Engine, although Fedora CoreOS images require setting up SSH access in advance, and troubleshooting information is provided for failed SSH connections."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4