I just tested your ask on Ubuntu VM with the same approach as you mentioned by adding multiple ssh pub keys under .ssh/authorized_keys and it is allowing multiple user login without any issue.
Managing multiple logins to Ubuntu Azure VM is no different as it is OS level operation.
Here are few checks that I would request you to validate on your end.
- Ensure that the
PubkeyAuthentication yes
is enabled in/etc/ssh/sshd_config
file - Restart the ssh service once you add the second public key in
~/.ssh/authorized_keys
Below are the repro steps for your reference :
- Created a Azure Ubuntu VM with password auth for testing this ask
- Created ssh key using
ssh-keygen -t rsa -b 2048
from another Ubuntu env (local Ubuntu instance) with a user1 - Copied the pub key created in the previous step to the Azure Ubuntu VM
- Added the copied pub key to authorized_keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
- Enabled the
PubkeyAuthentication yes
in/etc/ssh/sshd_config
file - Restarted the ssh service
sudo systemctl restart ssh
- Repeated the creation of ssh key for user2 on my local Ubuntu environment
- Followed the same instructions as mentioned above and was able to login from my local Ubuntu environment successfully.
Ubuntu VM:
SSH login to VM with User 1:
SSH login to VM with User 2:
Plz note: In this case both Password and SSH auth will work.
Hope the provided information is helpful. In case you have any further question please get back on this thread.
Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.