Connect to Linux VMs  |  Compute Engine Documentation  |  Google Cloud (2024)

  • Home
  • Compute Engine
  • Documentation
  • Guides
Stay organized with collections Save and categorize content based on your preferences.

Linux

This document describes how to connect to Linux virtual machine (VM) instancesthat have external IP addresses. To learn how to connect to VMs that don't haveexternal IP addresses, seeConnection options for internal-only VMs.

For information abouthow SSH connections work in Compute Engine, including SSH key configurationand storage, see SSH connections to Linux VMs.

Before you begin

  • If you haven't already, set up authentication. Authentication is the process by which your identity is verified for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine as follows.

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

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.

Console

Connect to VMs using SSH-in-Browser from theGoogle Cloud console, by doing the following:

  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.

    Connect to Linux VMs | Compute Engine Documentation | Google Cloud (1)

gcloud

Connect to a VM using SSH by running thegcloud compute ssh command:

  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. 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 VM
    • ZONE: the name of the zone that the VM is located in
    • VM_NAME: the name of the VM

    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

OpenSSH client

Connect to a VM using SSH from an OpenSSH client, do the following:

  1. Add an SSH key to the VM if you haven't already.
  2. 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.

    Go to VM Instances

  3. Open a terminal on your workstation.
  4. 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.

PuTTY app

Connect to a VM using SSH from the Windows PuTTY app, by doing the following:

  1. Add an SSH key to the VM if you haven't already.
  2. If your workstation doesn't already have the PuTTY app installed, download the PuTTY package files.
  3. 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.

    Go to VM Instances

  4. Open the PuTTY app. A connection configuration window opens.
  5. 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.
  6. In the Category menu, navigate to Connection> SSH> Auth.
  7. In the Private key file for authentication field, select the private SSH key file that corresponds to the public key you added to the VM.
  8. Click Open to connect to the VM.

Secure Shell Chrome app

To connect to a VM using SSH from the Secure Shell Chrome app, do thefollowing:

  1. Add an SSH key to the VM if youhaven't already.

  2. InstallSecure Shell on your Chromebook or Chrome browser if you have not done so already.

  3. In the Google Cloud console, go to the VM Instances page andfind the external IP address of the VM that you want to connectto.

    Go to VM Instances

  4. Open the Secure Shell in a Chrome browser tab address bar, by doing thefollowing:

    • Type ssh.
    • Press Space.
    • Press Enter.
  5. Click [New Connection].

  6. In the username field, enter your username. If you manage your SSHkeys in metadata, the username is what you specified when youcreated the SSH key. For OSLogin accounts, the username isdefined in your Google profile.For example, cloudysanfrancisco_example_com or cloudysanfrancisco.

  7. In the hostname field, enter the external IP address of the VM.

  8. In the Identity field, click Import... and select the path tothe private SSH key file that corresponds to the public key you added tothe VM.

  9. Click [ENTER] Connect 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 how SSH connections to Linux VMs work onCompute Engine.

Except 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 2024-09-10 UTC.

Connect to Linux VMs  |  Compute Engine Documentation  |  Google Cloud (2024)
Top Articles
Cost of living in Boston: Can you afford it?
Assassin's Creed Valhalla: How To Find The Powerful Isu Weapons
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 6273

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.