Jua*_*hez 2 git ssh spring-boot spring-cloud-config-server
我有一台 spring 配置服务器,但我将存储库更改为私有服务器,并且我正在尝试使用 SSH 身份验证。
我的 application.yml 是这样的:
spring:
cloud:
config:
server:
git:
uri: git@github.com:server/repo.git
ignoreLocalSshSettings: true
hostKey: githostkey
hostKeyAlgorithm: ssh-rsa
strictHostKeyChecking: true
passphrase: passphrase
privateKey : |
-----BEGIN RSA PRIVATE KEY-----
...............................
-----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
但当配置服务器尝试连接到存储库时,我收到此错误:
"org.eclipse.jgit.errors.NoRemoteRepositoryException:
git@github.com:server/repo.git: ERROR: You're using an RSA key with SHA-1, which is
no longer allowed. Please use a newer client or a different key type."
Run Code Online (Sandbox Code Playgroud)
Spring Cloud 文档在这里
建议使用“ssh-keygen -m PEM -t rsa -b 4096 -f ~/config_server_deploy_key.rsa”以正确的格式创建密钥对,我将公钥添加到我的 github 存储库中的 SSH 密钥中。
我用 'ssh -i ~/.ssh/config_server_deploy_key.rsa git@github.com' 检查生成的密钥,我得到:
Hi user! You've successfully authenticated, but GitHub does not provide shell
access.
Connection to github.com closed.
Run Code Online (Sandbox Code Playgroud)
但 git在这里公开了不支持 SHA-1 SSH,这支持了我首先得到的异常。
我正在尝试使用 'ssh-keygen -m PEM -t rsa-sha2-512 -C "myemail@server.com"' 生成有效密钥,但我有同样的问题。
任何人都可以给我线索吗?
我解决了这个问题
我通过这种方式获取 github 的所有主机密钥:
ssh -vvv git@github.com
Run Code Online (Sandbox Code Playgroud)
然后我用:
ssh-keygen -t ecdsa -b 256 -m PEM
Run Code Online (Sandbox Code Playgroud)
将新的公钥添加到我的存储库中,然后
uri: git@github.com:myserver/myRepo.git
ignoreLocalSshSettings: true
ignore-local-ssh-settings: true
hostKey: AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
hostKeyAlgorithm: ecdsa-sha2-nistp256
strictHostKeyChecking: true
passphrase: 'passphrase'
privateKey : |
-----BEGIN EC PRIVATE KEY-----
'''''''''''''''''''''''''''''''''
-----END EC PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
一切顺利!
| 归档时间: |
|
| 查看次数: |
5620 次 |
| 最近记录: |