When trying to connect to my Ubuntu 22.04 server Virtual Machine, my password seems incorrect. After resetting the password in the portal the connection is established again.

Martijn Beenker 0 Reputation points
2023-10-30T13:40:35.3233333+00:00

I'm deploying my VMs (Ubuntu 22.04 server) using PowerShell and Bicep. When trying to log in after a successful deployment using Bastion, the connection cannot be established. The browser shows the following message: Login failed. Please reconnect and try again..

When I take the password that got passed to my template and use it to reset the VM password in the portal and try again, the connection gets established. I believe this rules out any causes based on password policies by Ubuntu or Azure.

Maybe its due to the way I deploy the VMs? I generate two secure passwords using some PowerShell logic. Making sure there's numbers, lower case, upper case and special characters in both the passwords. The passwords get send to the Bicep template as secure objects and accessed in the osProfile part of the VM description. See example below.

After deployment I do not restart the VMs.

osProfile: {
      computerName: 'mountain-${i}'
      allowExtensionOperations: true
      adminPassword: adminPasswords['vm${i}']
      adminUsername: adminUsernames['vm${i}']
      linuxConfiguration: {
        patchSettings: {
          assessmentMode: 'AutomaticByPlatform'
          patchMode: 'AutomaticByPlatform'
          automaticByPlatformSettings: {
            rebootSetting: 'IfRequired'
          }
        }
      }
    }
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,479 questions
Azure Bastion
Azure Bastion
An Azure service that provides private and fully managed Remote Desktop Protocol (RDP) and Secure Shell (SSH) access to virtual machines.
247 questions
{count} votes

1 answer

Sort by: Most helpful
  1. deherman-MSFT 35,011 Reputation points Microsoft Employee
    2023-10-31T20:19:27.01+00:00

    @Martijn Beenker

    You mentioned that you generate two secure passwords using PowerShell logic and pass them as secure objects to the Bicep template. While this is a good practice, it’s possible that there might be an issue with how the passwords are being passed to the VMs.

    One thing you could try is to check if the passwords are being passed correctly to the osProfile part of the VM description. What happens when you manually do the passwords? You could also try restarting the VMs after deployment to see if that resolves the issue.

    1 person found this answer helpful.
    0 comments No comments