无法获得适用于 Azure Spring 云配置服务器的 public/private 密钥身份验证

Unable to get public/private key authentication working for Azure Spring Cloud Config Server

我在使用 Github 存储库作为后端的 Azure Spring 云中设置我的配置服务器时遇到困难。我使用基本身份验证工作,我在 Github 中创建了一个令牌,这对我的实验来说很好,但这不适合生产。

我已经在 Github 中设置了我的 public 密钥,并使用以下命令测试了我的设置是否正确,本质上是使用特定的私钥克隆了 repo:

GIT_SSH_COMMAND='ssh -i ../azure_id_rsa -o IdentitiesOnly=yes' git clone git@github.my-account/azure-config-server.git

在本地这工作得很好所以这似乎证实了我在 Github 中的设置是正确的并且使用私钥我应该能够克隆你认为的 Azure 中的存储库。

但是,如果我随后按照官方 Azure documentation 中描述的说明使用 GUI 设置我的配置服务器,我会收到以下错误:

Failed to update Config Server.
Reason: Fail to update config server due to 'Health check timeout with 10 minutes'.

所以我尝试通过上传 yaml 文件来使用“导入设置”选项。这个我用过 Azure template where I then paste my private key using the "private-key" section (and yes, the casing for Azure needs to be like that, according to the Azure documentation they only support the properties using hyphens rather than camel casing) as described here in the Spring documentation

但我总是遇到同样的错误,所以我认为我的设置有问题,但我的选择已经用尽了。如果有人有任何指示,将不胜感激。

好的,我明白了,只是在这里张贴我的答案以防它对某人有帮助。我刚刚注意到我的私钥与 Spring 示例中提到的私钥之间的一个区别。我的私钥以“-----BEGIN OPENSSH PRIVATE KEY-----”开头,而在 Spring 文档中它以“-----BEGIN RSA PRIVATE KEY-----”开头。换句话说,它希望它是 pem 格式而不是 OpenSSH 格式。

所以我现在通过生成我的密钥来让它工作,如下所示(值得注意的标志是“-m pem”):

ssh-keygen -t rsa -m pem -b 4096 -C "my@email.com"

然后,当我在 Github 中设置我的 public 密钥并将我的私钥粘贴到 Azure Config Server 中时,它确实起作用了。

希望这能帮助别人节省一些时间,因为我花了很多时间才弄明白。