This document describes how to connect to Linux virtual machine (VM) instances
using the Google Cloud Console and the gcloud
command-line tool. 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 Connecting to VMs using advanced methods.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
Connecting to VMs
To connect to Linux instances through the Google Cloud Console
or the gcloud
command-line tool, complete the steps in one of the following tabs.
Console
- In the Cloud Console, go to the VM instances page.
-
In the list of virtual machine instances, click SSH in the row of
the instance that you want to connect to.
gcloud
Use 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 instanceZONE
: the name of the zone in which the instance is locatedVM_NAME
: the name of the instance
If you have set default properties
for the gcloud
command-line tool, 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.
Troubleshooting
To find methods for diagnosing and resolving failed SSH connections, see Troubleshooting SSH.
What's next
- Learn how to Connect to Windows VMs.
- Learn how to manage access to instances.
- Learn how to connect to VMs using advanced methods.
- Learn how to transfer files to instances.
- Learn how SSH connections to Linux VMs work on Compute Engine.