title: Terraform Azure Linux VM with Azure AD Access
body: <p>I am trying to provision a simple Ubuntu Linux VM with Terraform that allows users to connect with their Azure AD credentials. I am new to Terraform and am trying to I'm trying to find the right resource section/command that enables the &quot;Login with Azure AD&quot; setting from the GUI shown in the screenshot link below.</p>
  <p>https://i.stack.imgur.com/Gg9p8.png</p>
  <p>Here is a snippet of code that provisions the VM:</p>
  <pre><code>resource &quot;azurerm_linux_virtual_machine&quot; &quot;dev&quot; {
    name                = &quot;devhost01&quot;
    resource_group_name = azurerm_resource_group.dev.name
    location            = azurerm_resource_group.ev.location
    size                = &quot;Standard_D2s_v3&quot;
    admin_username      = &quot;admin&quot;
    network_interface_ids = [
      azurerm_network_interface.dev.id,
    ]
  
    admin_ssh_key {
      username   = &quot;admin&quot;
      public_key = file(&quot;~/.ssh/admin.pub&quot;)
    }
  
    os_disk {
      caching              = &quot;ReadWrite&quot;
      storage_account_type = &quot;Standard_LRS&quot;
    }
  
    source_image_reference {
      publisher = &quot;Canonical&quot;
      offer     = &quot;UbuntuServer&quot;
      sku       = &quot;18.04-LTS&quot;
      version   = &quot;latest&quot;
    }
  }
  </code></pre>
  <p>I have a related but secondary question as well; I am unsure if it warrants a separate question/post. I manually created a VM through the GUI enabling &quot;Login with Azure AD&quot;, tried to connect with</p>
  <p><code>az ssh vm --ip XXX.XXX.XXX.XXX</code></p>
  <p>and received</p>
  <p><code>Permission denied (publickey).</code></p>
  <p>I haven't specified that users need to connect using ssh keys (at least not intentionally). Is there another section I need to add to allow basic SSH access for authenticated AD users?</p>