Stay organized with collections Save and categorize content based on your preferences.
Windows
Preview
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
This document describes how to connect to Windows virtual machine (VM) instances using SSH. For other ways to connect to Windows VMs, see Connect to Windows VMs using RDP and Connect to Windows VMs using PowerShell. To learn about how SSH works in Compute Engine, see About SSH connections.
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
.SSH for Windows is supported on Windows Server images running the guest agent (GCEGuestAgent
) version 20220527.00
or later and OpenSSH version 8.6
or later.
To enable SSH connections to Windows VMs, install the google-compute-engine-ssh
package and set the enable-windows-ssh
key to TRUE
in project or instance metadata. Enabling SSH for Windows in project metadata enables SSH for all Windows VMs in your project. Enabling SSH for Windows in instance metadata enables SSH for a single VM and overrides the value set in project metadata.
Enable SSH for Windows while creating a VM using the Google Cloud console or the Google Cloud CLI.
ConsoleCreate a VM from a public image that installs the google-compute-engine-ssh
package and enables SSH on startup:
Specify the following Boot disk properties:
In the Advanced options section, expand the Management section.
In the Metadata section, click Add item. Add a startup script that installs the google-compute-engine-ssh
package by entering the following metadata key-value pair:
sysprep-specialize-script-cmd
googet -noconfirm=true install google-compute-engine-ssh
In the Metadata section, click Add item. Set enable-windows-ssh
to TRUE
by entering the following metadata key-value pair:
enable-windows-ssh
TRUE
Click Create to create and start the VM.
Run the following gcloud compute instances create
command to create a Windows Server VM that installs the google-compute-engine-ssh
package and enables SSH on startup:
gcloud compute instances create VM_NAME \ --image-family=IMAGE_FAMILY \ --image-project=windows-cloud \ --metadata sysprep-specialize-script-cmd="googet -noconfirm=true install google-compute-engine-ssh",enable-windows-ssh=TRUE
Replace the following:
VM_NAME
: the name of the new VM.IMAGE_FAMILY
: a Windows Server image family. This creates the VM from the most recent non-deprecated Windows Server image.To enable SSH on a running Windows VM, do one of the following, depending on whether you can use RDP to access your VM or if your workload can tolerate a reboot:
Reboot required: Use a startup script to install the SSH package
If you can access your VM using RDP, enable SSH by doing the following:
Open an administrator Command Prompt session by doing the following:
Open the Start menu.
Navigate to Command Prompt.
Right-click Command Prompt and select Run as administrator.
If you are prompted to allow Command Prompt to make changes to your device, select Yes.
Download and install the google-compute-engine-ssh
package by running the following command:
googet -noconfirm=true install google-compute-engine-windows && googet -noconfirm=true install google-compute-engine-ssh
Close the RDP session.
Enable Windows SSH in metadata by setting the enable-windows-ssh
key to TRUE
. For more information about setting metadata, see Set custom metadata.
If you can't access your VM using RDP, enable SSH by doing the following:
Set the following metadata key-value pairs on the VM to enable SSH. For more information about setting metadata, see Set custom metadata.
SSH package installation metadata:
windows-startup-script-cmd
googet -noconfirm=true update && googet -noconfirm=true install google-compute-engine-ssh
SSH enablement metadata:
enable-windows-ssh
TRUE
Start the VM. The VM might take a few minutes to reboot.
Connect to VMs using the gcloud compute ssh
command:
gcloud compute ssh VM_NAME
Replace VM_NAME
with the name of the Windows VM that you want to connect to.
If the VM you're connecting to uses Active Directory (AD), connect using the following command:
gcloud compute ssh DOMAIN\USERNAME@VM_NAME
Replace the following:
DOMAIN
: your AD domain. For example the domain of the ad.example.com
AD, is example
.USERNAME
: your AD username. For example, cloudysanfrancisco
.VM_NAME
: the name of the Windows VM that you want to connect to.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 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 provides instructions on how to connect to Windows virtual machine (VM) instances using SSH, as an alternative to RDP or PowerShell connections."],["To enable SSH for Windows VMs, you must install the `google-compute-engine-ssh` package and set the `enable-windows-ssh` key to `TRUE` in either project or instance metadata."],["When creating a new Windows VM, you can enable SSH during setup by adding a startup script to install the SSH package and setting the `enable-windows-ssh` metadata key to `TRUE`."],["For existing running Windows VMs, SSH can be enabled by either connecting via RDP to install the package or by stopping the VM, adding metadata for a startup script to install the package, and setting the `enable-windows-ssh` key, followed by restarting the VM."],["The `gcloud compute ssh` command is used to establish an SSH connection to a Windows VM, and for VMs using Active Directory, the command needs to include the domain and username in the format `DOMAIN\\USERNAME@VM_NAME`."]]],[]]
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