Forum Discussion
Azure powershell Set-AzStorageLocalUser - how to use existing ssh key in azure?
- Oct 08, 2024
Please try these steps.
1. Get the SSH Key: You need to manually retrieve the SSH key from Azure.
2. Base64 Encode the Key: Convert the SSH key into Base64 format to ensure it's properly formatted.
3. Use the Key: Finally, use the Set-AzStorageLocalUser command to assign the SSH key to your new local user.There is no built-in PowerShell command to directly pull and assign an existing SSH key automatically like you can in the Azure Portal. You have to handle it in these steps.
Reference URL: https://learn.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys
Many Thanks
Balasubramani.M
balasubramanim Thank you for the reply.
We are expecting the option to handle the pulling and assigning the key by Azure powershell command, similar to the Portal UI.
Do we have that option ?
In case, our powershell script need to do it, there are 3 steps
1. Pull the ssh key from Azure SSH keys
2. Base 64 encrypt the key
3. Upload the key with the Set-AzStorageLocalUser command.
This has possibility of error in the format, encryption etc.
Please try these steps.
1. Get the SSH Key: You need to manually retrieve the SSH key from Azure.
2. Base64 Encode the Key: Convert the SSH key into Base64 format to ensure it's properly formatted.
3. Use the Key: Finally, use the Set-AzStorageLocalUser command to assign the SSH key to your new local user.
There is no built-in PowerShell command to directly pull and assign an existing SSH key automatically like you can in the Azure Portal. You have to handle it in these steps.
Reference URL: https://learn.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys
Many Thanks
Balasubramani.M
- GirishPrabhudesaiOct 08, 2024Copper ContributorThanks, I will try these steps