Forum Discussion
GirishPrabhudesai
Oct 07, 2024Copper Contributor
Azure powershell Set-AzStorageLocalUser - how to use existing ssh key in azure?
I am trying to build powershell script to create a local user for sftp in the Azure Stroage account. We have ssh keys already created in Azure. When the local user is created, existing ssh key c...
- 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
GirishPrabhudesai
Oct 08, 2024Copper Contributor
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.
balasubramanim
Oct 08, 2024Iron Contributor
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