Creating passwords for Windows VMs

Windows Server instances use password authentication instead of SSH authentication. To prevent unauthorized access to new Windows instances, Compute Engine requires that you generate a new Windows password for that instance before you connect to it. If you forget your password, you can generate a new one using this same process.

Before you begin

Generating a password

You can generate Windows passwords using either the Google Cloud Console or the gcloud command-line tool. Alternatively, you can generate passwords programmatically with API commands. If you forget your password, you can also use this procedure to reset it.

Permissions required for this task

To perform this task, you must have the following permissions:

  • compute.instances.admin role on the project
  • iam.serviceAccountUser role on the service account

Console

  1. Go to the VM instances page.

    Go to the VM instances page

  2. Click the Windows VM to change the password on.

  3. On the VM instance details page, click Set Windows password.

  4. In the Username field, enter the username to change the password for, or enter a new username to create a new user.

  5. Click Set.

gcloud

Use the gcloud compute reset-windows-password command to create a new account and password or reset the existing account password for the logged in user:

gcloud compute reset-windows-password instance-name

You will be presented with a confirmation prompt; this will need to be accepted by entering Y and/or pressing Enter. It can be rejected by entering N, then pressing Enter.

This command creates an account and sets an initial password for the
user [username] if the account does not already exist.
If the account already exists, resetting the password can cause the
LOSS OF ENCRYPTED DATA secured with the current password, including
files and stored passwords.

For more information, see:
https://cloud.google.com/compute/docs/operating-systems/windows#reset

Would you like to set or reset the password for [username] (Y/n)?

Once confirmed, confirmation of password reset will look as follows.

Resetting and retrieving password for [username] on [instance-name]
Updated [https://www.googleapis.com/compute/v1/projects/project-name/zones/zone/instances/instance-name].
ip_address: ip-address
password:   password
username:   username

You may now connect to the instance using the provided username and password combination.

Changing a password

Compute Engine generates a random password, but you should change the password to a custom password that is meaningful to you. To set a custom password, connect to your Windows VM instance using the generated password, and then do the following:

Command prompt

  1. Use the net user command to change the password.

Windows Server 2012 R2

  1. After the desktop finishes loading, click the Start menu icon.

  2. Click Control Panel.

  3. Under the User Accounts icon, click either Change Account Type or Add or remove user accounts.

  4. Select the account that you want to modify.

  5. Click Change the password.

  6. Enter your current password and your new password.

  7. Click Change password to save your changes.

Windows Server 2016

  1. After the desktop finishes loading, click the Start menu icon.

  2. Click Control Panel.

  3. Under the User Accounts icon, click either Change Account Type or Add or remove user accounts.

  4. Select the account that you want to modify.

  5. Click Change the password.

  6. Enter your current password and your new password.

  7. Click Change password to save your changes.

Windows Server 2019

  1. After the desktop finishes loading, click the Start menu icon.

  2. Click Settings.

  3. Click Accounts.

  4. Click Sign-in options.

  5. Under Password, click Change.

  6. Enter your current password and click Next.

  7. Enter your New password, in Reenter password enter the new password again, enter a Password hint, and click Next.

  8. Click Finish.

What's next