Computenext inc
Computenext inc

Reputation: 1

I couldn't connect GCE windows instance from remmina RDP

I use GCE V1 rest api to launch instances. I rarely use google developer console. I created windows VM instance through rest api. I passed windows initial username and password in metadata property. Windows VM created successfully. I also able to get those credentials in response, which I sent while creating VM. But I couldn't connect the VM using that username and password. I read the doc about how to reset password from developer console. It works fine. But we would like to rest apis for all. I mean to created/manage GCE resources. So can anyone help to fix this issue?

The image I used to launch a vm is "windows-server-2012-r2-dc-v20150511"

"metadata": {
    "items": [
      {
        "key": "gce-initial-windows-user",
        "value": "administrator"
      },
      {
        "key": "gce-initial-windows-password",
        "value": "twxsFL3U-/,*"
      }
    ]
  }

Note: I created many VMs through rest api. All instances have the same issue. When reseting the password from developer console, it works.

The credentials didn't work. I am able to reset them from developer console. But that will not fix my problem. Because we have our own system to launch VMs and other services. For that I'm building a connector. Here is the sample request I send from node.js script.

Request :
***********
options : {
  "host": "www.googleapis.com",
  "path": "/compute/v1/projects/project-id/zones/us-central1-f/instances",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer ya29.lQGsX8hwdWKaDDwOFnDIZB49eir-c2TUBqYpaVvir7C430Quy8kIWsL4rXv7qjSVQZJKK5e1BdxNug",
    "Content-Type": "application/json charset=utf-8"
  }
}  

 body : {
  "name": "rin2qvxkz-e",
  "zone": "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f",
  "machineType": "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/machineTypes/n1-standard-2",
  "metadata": {
    "items": [
      {
        "key": "gce-initial-windows-user",
        "value": "administrator"
      },
      {
        "key": "gce-initial-windows-password",
        "value": "%1zuV27$.:?*"
      }
    ]
  },
  "tags": {
    "items": [
      "default"
    ]
  },
  "disks": [
    {
      "type": "PERSISTENT",
      "boot": true,
      "mode": "READ_WRITE",
      "deviceName": "rin2qvxkz-e",
      "autoDelete": true,
      "initializeParams": {
        "sourceImage": "https://www.googleapis.com/compute/v1/projects/windows-cloud/global/images/windows-server-2012-r2-dc-v20150511",
        "diskType": "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/diskTypes/pd-standard"
      }
    }
  ],
  "canIpForward": false,
  "networkInterfaces": [
    {
      "network": "https://www.googleapis.com/compute/v1/projects/project-id/global/networks/default",
      "accessConfigs": [
        {
          "name": "External NAT",
          "type": "ONE_TO_ONE_NAT"
        }
      ]
    }
  ],
  "description": "rin2qvxkz-e",
  "scheduling": {
    "preemptible": false,
    "onHostMaintenance": "MIGRATE",
    "automaticRestart": true
  }
}

Thanks.

Upvotes: 0

Views: 789

Answers (2)

Greg Long
Greg Long

Reputation: 51

The earlier answer didn't really explain when this changed. I did more research and found a note in the change log for Google Windows Images.

Metadata items gce-initial-windows-user and gce-initial-windows-password will no longer work for images v20150511 and later

https://cloud.google.com/compute/docs/release-notes-archive#february_2015

June 03, 2015

Updated Windows authentication process. Windows images v20150511 and later will use the new scheme by default. gcloud will now generate a random password for Windows login; it is no longer possible to manually set a Windows password through gcloud but you can set a custom password in the instance.

Here are some links that detail how to Add users to windows Images now

  • You can use the gcloud command line tool

https://cloud.google.com/sdk/gcloud/reference/compute/reset-windows-password

gcloud compute reset-windows-password INSTANCE_NAME [--user=USER] [--zone=ZONE] [GCLOUD_WIDE_FLAG …]

  • You can call the API, They give GO and Python examples
  • They also detail a Step-By-Step manual process, in case you want more details

https://cloud.google.com/compute/docs/instances/windows/automate-pw-generation

Upvotes: 1

Alexander Gaysinsky
Alexander Gaysinsky

Reputation: 161

You are using a new Windows image "windows-server-2012-r2-dc-v20150511" with an updated GCEAgent that doesn't look at the gce-initial-windows-user/gce-initial-windows-password instance metadata keys which were used by the old authentication scheme.

Here are explanations of how the new authentication works, starting from the "windows-server-2012-r2-dc-v20150511" image and onwards.

Please note that the initial Windows authentication and GCE API v1 are two separate topics and GCE API v1 has not changed as part of the authentication update.

Upvotes: 1

Related Questions