dolor3sh4ze
dolor3sh4ze

Reputation: 1165

Can't deploy Azure VM with SSH configuration

I try to deploy a VM machine with Azure but when I deploy I've this message below:

{
    "status": "Failed",
    "error": {
        "code": "InvalidParameter",
        "target": "linuxConfiguration",
        "message": "Authentication via SSH or username and password must be enabled in the Linux profile."
    }
}

Template ARM:

https://pastebin.com/u4ZrhBvs

I added the ARM template above, but for this deployment I used the Azure portal entirely. I will use the template later

I don't really understand how can I fix that because the VM is not created and I don't have access to it?

Upvotes: 2

Views: 1277

Answers (1)

Andriy Bilous
Andriy Bilous

Reputation: 2522

In your ARM template you disabled password authentication but did not specified SSH key options

                "osProfile": {
                "computerName": "[parameters('virtualMachineComputerName')]",
                "adminUsername": "[parameters('adminUsername')]",
                "linuxConfiguration": {
                    "disablePasswordAuthentication": true
                }
            },

Your osProfile with SSH key option should look like this

"osProfile": {
          "computerName": "[variables('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "linuxConfiguration": {
            "disablePasswordAuthentication": true,
            "ssh": {
              "publicKeys": [
                {
                  "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
                  "keyData": "[parameters('adminPublicKey')]"
                }
              ]
            }
          }
        },

Here is an example how to create Linux VM from ARM template

https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-ssh-secured-vm-from-template

Upvotes: 3

Related Questions