azure-cli-extensions
azure-cli-extensions copied to clipboard
Creating local user with public key failed to validate key
Related command
az storage account local-user create --account-name accname -g private_rg -n sftpuser --home-directory sftp --permission-scope permissions=rwlcd service=blob resource-name=sftp --ssh-authorized-key key="*SSH_KEY*" --has-ssh-key true
Extension name
storage-preview
Description of issue
When supplying the contents of a rsa .pub
file to the key
property, I get the below error.
I did notice the trailing =
seem to get dropped in the output not sure if they are maybe getting dropped on input.
Error:
Code: InvalidBase64String
Message: String AAAAB3Nza...g04Dyy6Iw is not base64 encoded.
I've also tried base64 encoding the contents on the rsa .pub
file and supplying that in the key data section but that results in the same error.
Key was generated using ssh-keygen -m PEM -t rsa -b 4096 -f ./keyfile
OS: macOS Monterey - 12.3.1 (21E258) Shell: ZSH
storage
Hi, I've also been hitting this (it also seems to affect updating local users, as well as creating them).
From a quick code-read, it looks like this might be quite a simple fix to src/storage-preview/azext_storage_preview/_validators.py
- replacing the line key = k.split('=')[1]
with key = k.split('=', 1)[1]
in SshPublicKeyAddAction.__call__()
method (i.e. rather than splitting on every =
, just split on the first instance and take the remainder of the string as the value wanted). I tested this by patching my local install and this seemed to fix the issue (my generated SSH key also had a trailing =
in the key, which was previously getting dropped but with this change was now included, and I could see the full expected key present for the user in the Azure portal after running the command).
I'm happy to create a PR for fixing this if that would be helpful?