Welcome to Microsoft Q&A Platform, thanks for posting your query here.
As you already have created ssh key pair using ssh-keyggen command, login to the Linux VM as root user (azureuser
).
Else you can check this document on how to create a ssh key pairs.
Once logged into Azure VM, create a new user as shown in below screenshot using useradd
command:
sudo useradd username
In Azure portal, select the VM and go to Reset Password option and give the newly created user name and public key of the new user that you have already created and click on update to update the SSH key login for the new user.
Once the SSH login is updated for new user, you can SSH into the VM with newuser@publicip
by providing the private key through putty or directly depending on how you are accessing the VM.
You can verify the login user once as shown below:
Also, you can run below command to list down the root/super users, this is to make sure that you ask of non-root/non-sudo is verified.
This command list down the privileged users only. The newly created user will not be in the list as it is a non-root user.
grep '^sudo:.*$' /etc/group | cut -d: -f4
Hope this helps.
If you need further help on this, tag me in a comment.
If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.