本文介绍了USERAUTH失败,并带有Github和Spring云配置的私钥文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用使用私钥的方法(该私钥具有密码,并且已从文件添加到ssh-agent中)(根据堆栈帖子):

I tried to use the method for using private key (that has passphrase and is added to ssh-agent from file) (according to this stack post):

spring:
  cloud:
    config:
      server:
        git:
          uri: git@github.com-forApp:myorg/myrepo.git
          search-paths: '{application}'
          clone-on-start: true
          private_key_file: ~/.ssh/id_rsa

但我不断得到

我是否必须完全按照文档进行操作说并将密钥粘贴到配置文件中,还是可以以某种方式仅指向密钥文件?

Do I have to do it exactly as doc says with pasting the key into config file or can one just point to the key file somehow?

编辑

实际上,事实证明private_key_file根本不需要或未被Spring忽略.但是您需要~/.ssh/config部分指向私钥才能使用:

Actually it turns out that the private_key_file is not needed at all or ignored by Spring. But you need the ~/.ssh/config section pointing to private key to use:

Host github.com-forApp # used in spring uri 
       HostName github.com
       User git
       IdentityFile ~/.ssh/gitHubKey

推荐答案

我能够复制您的行为,并通过以下方法解决了它.让我知道你的想法.

I was able to replicate your behavior and resolved it with following. Let me know your thoughts.

USERAUTH fail之所以发生,是因为您没有提供RSA私钥的密码短语.(password代表Basic Auth,passphrase代表ssh私钥)

USERAUTH fail is happening because you are not providing the passphrase for the RSA private key.(password for Basic Auth and passphrase for ssh private key)

spring:
  cloud:
    config:
      server:
        git:
          uri: git@github.com:myorg/myrepo.git
          search-paths: '{application}'
          clone-on-start: true
          passphrase: myprivatekeypassword

默认情况下,~/.ssh/id_rsa是在GIT SSH身份验证期间发送的(使用命令ssh -vT git@github.com测试.您无需在配置中指定它.而且,我不确定private_key_file是否有效,因为我没有没有任何官方文档.

By default ~/.ssh/id_rsa is sent during GIT SSH Authentication(Test with command ssh -vT git@github.com. You don't need to specify it in configuration. Also, I am not sure whether private_key_file works or not, since I don't see any official documentation for it.

如果您在.ssh下有一个不同的命名RSA文件,那么我建议在~/.ssh/config下使用github主机详细信息创建配置文件并识别该文件.

If you have different named RSA file under .ssh then I would advise to create config file under ~/.ssh/config with github host details and identify file.

这里是一个例子.

Host github.com
    IdentityFile ~/.ssh/mygitid_rsa

检查堆栈答案以获取更多详细信息,这些详细信息需要配置在config中提供私钥文件路径.

Check this stack answer for more details which desired the configuration providing private key file path within config.

这篇关于USERAUTH失败,并带有Github和Spring云配置的私钥文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 08:16