Connect to Linux VMs using Google tools

Stay organized with collections Save and categorize content based on your preferences.

This document describes how to connect to Linux virtual machine (VM) instances using the Google Cloud console and the Google Cloud CLI. For information about how SSH connections work in Compute Engine, including SSH key configuration and storage, see SSH connections to Linux VMs.

For other ways to connect to Linux VMs, such as using third-party tools including PuTTY, see Connect to Linux VMs using third-party tools.

Before you begin

Supported operating systems

These connection methods are supported for all Linux operating systems that are available on Compute Engine. For Fedora CoreOS, you must set up SSH access before you can use these methods.

Connect to VMs

To connect to Linux instances through the Google Cloud console or the Google Cloud CLI, complete the steps in one of the following tabs.


  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to.

    SSH button next to instance name.


  1. In the Google Cloud console, activate Cloud Shell.

    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.

  2. In your development environment, run the gcloud compute ssh command to connect to instances that you have permission to access:

    gcloud compute ssh --project=PROJECT_ID --zone=ZONE VM_NAME

    Replace the following:

    • PROJECT_ID: the ID of the project that contains the instance
    • ZONE: the name of the zone in which the instance is located
    • VM_NAME: the name of the instance

    If 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

After you connect, use the terminal to run commands on your Linux instance. When you have finished, disconnect from the instance by using the exit command.


To find methods for diagnosing and resolving failed SSH connections, see Troubleshooting SSH.

What's next