我正在使用 Terraform 构建 Azure DevOps 管道。该管道创建一个 Linux 服务器,然后登录 Linux 服务器来更新软件包并安装 Apache。
我目前将私钥存储在我的 BitBucket 存储库中(我知道,这不是最佳实践),然后将其拉到构建代理服务器上,然后使用以下命令登录到新服务器:
ssh -f -q -o BatchMode=yes -o StrictHostKeyChecking=no -i ../private_key.pem ubuntu@$ip sudo apt update -y
在 Azure DevOps 中存储和检索私钥的最佳方式是什么?
最佳答案
我能想到的两个选择:
1) 在 azure DevOps 中创建 ssh 服务连接。引用管道中的服务连接。 https://medium.com/@sibeeshvenu/ssh-deployment-task-in-azure-pipelines-b0e2923bd7b4
2) 将 SSH key 存储为 Azure Key Vault secret ,然后在构建过程中使用 Azure CLI 下载该 secret 。
az keyvault secret download --name mysshkey --vault-name mykeyvault --file ~/.ssh/id_rsa
使用服务主体对 Azure CLI 进行身份验证,并使用变量组向管道提供凭据。
关于linux - 在 Azure DevOps Pipeline 中提供 SSH 私钥的最佳方式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56498563/