id_rsa 上传到 Azure Key Vault。
azure keyvault secret set --name shui --vault-name shui --file ~/.ssh/id_rsa
你可以使用-h来获取帮助。
--file <file-name> the file that contains the secret value to be uploaded; cannot be used along with the --value or --json-value flag
你还可以从密钥保管库下载秘密。
az keyvault secret download --name shui --vault-name shui --file ~/.ssh/id_rsa
我比较了实验室里的钥匙,它们是一样的。
az keyvault secret set --vault-name 'myvault' -n 'secret-name' -f '~/.ssh/id_rsa'
Arguments
--name -n [Required]: Name of the secret.
--vault-name [Required]: Name of the key vault.
--description : Description of the secret contents (e.g. password, connection string,
etc).
--disabled : Create secret in disabled state. Allowed values: false, true.
--expires : Expiration UTC datetime (Y-m-d'T'H:M:S'Z').
--not-before : Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z').
--tags : Space-separated tags in 'key[=value]' format. Use '' to clear existing
tags.
Content Source Arguments
--encoding -e : Source file encoding. The value is saved as a tag (`file-
encoding=<val>`) and used during download to automatically encode the
resulting file. Allowed values: ascii, base64, hex, utf-16be,
utf-16le, utf-8. Default: utf-8.
--file -f : Source file for secret. Use in conjunction with '--encoding'.
--value : Plain text secret value. Cannot be used with '--file' or '--encoding'.
Global Arguments
--debug : Increase logging verbosity to show all debug logs.
--help -h : Show this help message and exit.
--output -o : Output format. Allowed values: json, jsonc, table, tsv. Default:
json.
--query : JMESPath query string. See http://jmespath.org/ for more information
and examples.
--verbose : Increase logging verbosity. Use --debug for full debug logs.
使用jq工具将密钥保存到文件~/.ssh/mykey中。
az keyvault secret show --vault-name myvault --name 'secret-name' | jq -r .value > ~/.ssh/mykey
文件可能会打印出一个尾随的换行符,你可以使用 Perl 的一行命令来删除它:
perl -pi -e 'chomp if eof' ~/.ssh/mykey
# Set permissions to user-read only
chmod 600 ~/.ssh/mykey
从私钥文件生成公钥...
ssh-keygen -y -f ~/.ssh/myfile > ~/.ssh/myfile.pub
$az keyvault secret set –-vault-name <KEY_VAULT_NAME> -–name <NAME_OF_THE_KEY> –-file <PATH_OF_THE_SSH_KEY_FILE> -–encoding ascii
-uand-sflags refer to the options available inazure-cli (2.0.14). - s gaz keyvault secret download --name <KeyNameHere> --vault-name <vaultNamehere> --file <filename here>- Gregory Suvalian