我试图使用使用私钥的方法(具有密码短语,并且已从文件添加到ssh-agent中)(根据此堆栈文章):
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
Run Code Online (Sandbox Code Playgroud)
但我不断
org.eclipse.jgit.api.errors.TransportException:git@github.com:myorg / myrepo.git:USERAUTH失败
将密钥粘贴到配置文件中时,我是否必须完全按照doc所述进行操作,还是可以以某种方式仅指向密钥文件?
编辑
实际上,事实证明private_key_file根本不需要或Spring忽略了。但是您需要使用~/.ssh/config指向私钥的部分:
Host github.com-forApp # used in spring uri
HostName github.com
User git
IdentityFile ~/.ssh/gitHubKey
Run Code Online (Sandbox Code Playgroud)