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.
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-24 UTC。"],[[["\u003cp\u003eThis 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.\u003c/p\u003e\n"],["\u003cp\u003eCompute 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.\u003c/p\u003e\n"],["\u003cp\u003eBefore connecting, users should set up authentication and can install the Google Cloud CLI and set a default region and zone.\u003c/p\u003e\n"],["\u003cp\u003eSSH 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.\u003c/p\u003e\n"],["\u003cp\u003eSupported 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.\u003c/p\u003e\n"]]],[],null,["Linux\n\n*** ** * ** ***\n\nThis document describes how to connect to Linux virtual machine (VM) instances\nthat have external IP addresses by using SSH keys. To learn how to connect to\nVMs that don't have external IP addresses, see\n[Connection options for internal-only VMs](/compute/docs/connect/ssh-internal-ip).\nTo learn how to connect to Linux VMs using SSH certificates, see\n[Require SSH certificates for OS Login VMs](/compute/docs/oslogin/certificates).\n\nFor information about\nhow SSH connections work in Compute Engine, including SSH key configuration\nand storage, see [SSH connections to Linux VMs](/compute/docs/instances/ssh).\n| **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.\n\nBefore you begin\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n gcloud\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\nSupported operating systems\n\nThese connection methods are supported for all\n[public Linux images](/compute/docs/images/os-details) that are available on\nCompute Engine. For Fedora CoreOS images, you must\n[set up SSH access](https://docs.fedoraproject.org/en-US/fedora-coreos/tutorial-containers/)\nbefore you can use these methods.\n\nConnect to VMs\n\nTo connect to a VM, complete the steps in one of the following tabs. \n\nConsole\n\nConnect to VMs using [SSH-in-browser](/compute/docs/ssh-in-browser) from the\nGoogle Cloud console, by doing the following:\n\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n2. In the list of virtual machine instances, click **SSH** in the row of the instance that you want to connect to.\n\n\u003cbr /\u003e\n\n| **Note:** When you connect to VMs using the Google Cloud console, Compute Engine creates an ephemeral SSH key for you. For more information about SSH keys, see [SSH connections to Linux VMs](/compute/docs/instances/ssh).\n\ngcloud\n\nConnect to a VM using SSH by running the\n[`gcloud compute ssh` command](/sdk/gcloud/reference/compute/ssh):\n\n1. In the Google Cloud console, activate Cloud Shell.\n2. [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n3. At the bottom of the Google Cloud console, a [Cloud Shell](/shell/docs/how-cloud-shell-works) 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.\n4. Run the following command:\n\n ```\n gcloud compute ssh --project=PROJECT_ID --zone=ZONE VM_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of the project that contains the VM\n - \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the name of the zone that the VM is located in\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the VM\n\n If you have [set default\n properties](/compute/docs/gcloud-compute#default-properties) for the Google Cloud CLI, you can omit the `--project` and\n `--zone` flags from this command. For example: \n\n ```\n gcloud compute ssh VM_NAME\n ```\n\n| **Note:** When you connect to VMs using the gcloud CLI, Compute Engine creates a persistent SSH key for you. For more information about SSH keys, see [SSH connections to Linux VMs](/compute/docs/instances/ssh).\n\nOpenSSH client\n\nConnect to a VM using SSH from an OpenSSH client, do the following:\n\n1. [Add an SSH key to the VM](/compute/docs/connect/add-ssh-keys) if you haven't already.\n2. In the Google Cloud console, go to the **VM Instances** page and find the\n\n external IP address\n\n of the\n\n VM that you want to connect to.\n\n [Go to VM Instances](https://console.cloud.google.com/compute/instances)\n3. Open a terminal on your workstation.\n4. Connect to the\n\n VM by running the following command:\n\n ```\n ssh -i PATH_TO_PRIVATE_KEY USERNAME@EXTERNAL_IP\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY\u003c/var\u003e: the path to the private SSH key file that corresponds to the public key you added to the VM.\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your username. If you manage your SSH keys in metadata, the username is what you specified when you [created the SSH key](/compute/docs/connect/create-ssh-keys). For OS Login accounts, the username is [defined in your Google profile](/compute/docs/connect/add-ssh-keys#os-login). For example, `cloudysanfrancisco_example_com` or `cloudysanfrancisco`.\n - \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e: the external IP address of the VM.\n\nPuTTY app\n\nConnect to a VM using SSH from the Windows PuTTY app, by doing the following:\n\n1. [Add an SSH key](/compute/docs/connect/add-ssh-keys) to the VM if you haven't already.\n2. If your workstation doesn't already have the PuTTY app installed, [download the PuTTY package files](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html).\n3. In the Google Cloud console, go to the **VM Instances** page and find the\n\n external IP address\n\n of the VM that you want to connect to.\n\n [Go to VM Instances](https://console.cloud.google.com/compute/instances)\n4. Open the PuTTY app. A connection configuration window opens.\n5. In the `Host Name` field, enter the username associated with the SSH key, and\n the\n\n external IP address\n\n of the VM that you want to connect to. Use the following format:\n\n ```\n USERNAME@EXTERNAL_IP\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your username. If you manage your SSH keys in metadata, the username is what you specified when you [created the SSH key](/compute/docs/connect/create-ssh-keys). For OS Login accounts, the username is [defined in your Google profile](/compute/docs/connect/add-ssh-keys#os-login). For example, `cloudysanfrancisco_example_com` or `cloudysanfrancisco`.\n - \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e: the external IP address of the VM.\n6. In the **Category** menu, navigate to **Connection \\\u003e\n SSH \\\u003e Auth**.\n7. 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.\n8. Click **Open** to connect to the VM.\n\nSecure Shell Chrome app\n\nTo connect to a VM using SSH from the Secure Shell Chrome app, do the\nfollowing:\n\n1. [Add an SSH key to the VM](/compute/docs/connect/add-ssh-keys) if you\n haven't already.\n\n2. Install\n [Secure Shell](https://chrome.google.com/webstore/detail/secure-shell/iodihamcpbpeioajjeobimgagajmlibd)\n on your Chromebook or Chrome browser if you have not done so already.\n\n3. In the Google Cloud console, go to the **VM Instances** page and\n find the external IP address of the VM that you want to connect\n to.\n\n [Go to VM Instances](https://console.cloud.google.com/compute/instances)\n4. Open the Secure Shell in a Chrome browser tab address bar, by doing the\n following:\n\n - Type `ssh`.\n - Press `Space`.\n - Press `Enter`.\n5. Click **\\[New Connection\\]**.\n\n6. In the **username** field, enter your username. If you manage your SSH\n keys in metadata, the username is what you specified when you\n [created the SSH key](/compute/docs/connect/create-ssh-keys). For OS\n Login accounts, the username is\n [defined in your Google profile](/compute/docs/connect/add-ssh-keys#os-login).\n For example, `cloudysanfrancisco_example_com` or `cloudysanfrancisco`.\n\n7. In the **hostname** field, enter the external IP address of the VM.\n\n8. In the **Identity** field, click **Import...** and select the path to\n the private SSH key file that corresponds to the public key you added to\n the VM.\n\n9. Click **\\[ENTER\\] Connect** to connect to the VM.\n\nTroubleshooting\n\nTo find methods for diagnosing and resolving failed SSH connections, see\n[Troubleshooting SSH](/compute/docs/troubleshooting/troubleshooting-ssh).\n\n\nWhat's next\n\n- Learn how to [manage access to VMs](/compute/docs/instances/access-overview).\n- Learn how to [transfer files to VMs](/compute/docs/instances/transfer-files).\n- Learn how [SSH connections to Linux VMs](/compute/docs/instances/ssh) work on Compute Engine."]]