I’ve looked in a lot of places for this information, and have turned up very little.
I have an Azure Linux VM. I use SSH to access it, and I provided public RSA key for that during deployment.
I now need to remote access it over SSH from another machine. But I have been unable to find information on how I can add a second public RSA key to it. The information I kept seeing was that it can only be accessed with one key. Is this correct, or can I use ssh-copy-id to send another public key to it from the 2nd remote computer I would like to access it from?
Advertisement
Answer
Whilst the various answers related to copying a new ssh key to the server may work, I was avoiding that approach for the following reasons (which mostly come down to my ignorance about how Azure VMs):
1) Azure VMs appear to be set up to allow either Password access or Key access. Based on the documentation I read, it was not clear to me whether changing from one to the other eliminates the prior setting, etc., so I didn’t go down that road.
2) The other thing is that, in my experience, the documentation about managing Key access is not clear. Reading through it, and through many related questions on forums, I wrongly got the impression Azure only allows adding one user/RSA key pair to a VM.
By trial and error, I eventually figured out that what the Portal refers to as “Reset Password” and “Update” (changes made to the password/key) is not really only about resetting and updating at all. One can use the Reset/Update process to ADD a new user/key pair, without losing existing pairs. Basically, the user/key/password management system on Azure Portal is poorly thought out, and rather ambiguous (even misleading) in its terminology.
So the solution to my original question is to simply add a new user/key paid to the “Reset password” interface.
It should be noted that if the sshd_config on the server limits SSH to uses in specific groups, the user newly added through the Portal will need to be added to at least one of those groups via the command terminal.