MoonHorse
MoonHorse

Reputation: 2479

Terraform Azurerm error: linuxConfiguration.ssh.publicKeys.path is invalid

I am using Terraform v0.12.24 with provider.azurerm v2.2.0 I get this error below when i try to create scaleset VMs:

Error: compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter linuxConfiguration.ssh.publicKeys.path is invalid." Target="linuxConfiguration.ssh.publicKeys.path"

on scaleset.tf line 1, in resource "azurerm_virtual_machine_scale_set" "demo": 1: resource "azurerm_virtual_machine_scale_set" "demo" {

I am using Windows 10 for the terraform configuration. My os_profile_linux_config is as below:

       storage_profile_image_reference {
        publisher = "Canonical"
        offer     = "UbuntuServer"
        sku       = "18.04-LTS"
        version   = "latest"
      }

  os_profile_linux_config {
    disable_password_authentication = true

    ssh_keys {
      key_data = file("C:/Users/jack/Documents/key/id_rsa.pub")
      path     = "C:/Users/jack/Documents/key"
    }
  }

First, i have tried two different key pairs. one is created by puttygen and the other by ssh-keygen with git bash. I had the same error with both of them. Do you have any idea?

Upvotes: 2

Views: 3664

Answers (1)

Charles Xu
Charles Xu

Reputation: 31384

For your issue, I think you misunderstand the property path of the ssh_key, it shows here:

ssh_keys - (Optional) Specifies a collection of path and key_data to be placed on the virtual machine.

It's the path inside the VM that you want to create, not the path of the machine that you execute the Terraform. And also:

Note: Please note that the only allowed path is /home//.ssh/authorized_keys due to a limitation of Azure.

Upvotes: 5

Related Questions