gpt4 book ai didi

github - Spring Cloud/Jgit/Github无法使用SSH

转载 作者:行者123 更新时间:2023-12-02 14:27:26 25 4
gpt4 key购买 nike

  • Windows 10专业版x64
  • JDK 11.0.6
  • spring-cloud-config-server 2.2.2。发布

  • 我正在设置Spring Cloud Config服务器。在文件系统后端正常工作。可以与 https /基本身份验证 github后端配合使用。现在,我正在尝试将其设置为使用SSH,因此不必在配置文件中输入用户名和密码。

    据我了解,Spring Cloud Config / jgit将使用所有默认的SSH设置,对吗?我已经完成以下工作:
  • ssh-keygen -m PEM -t rsa -b 4096 -C "xxx@xxx.net"-接受所有默认文件,没有密码短语。文件在C:\ Users \ xxx.ssh中创建。
  • 打开c:\ users \ xxx.ssh \ id_rsa.pub,选择全部,c&p到github
  • 运行git clone git@github.com:xxx/Config.git,将SHA256指纹复制到yes / no / fingerprint提示中,克隆成功
  • 编辑了known_hosts并删除了IP,因此现在它仅读取github.com ssh-rsa AAAA...
  • application.properties:

    spring.cloud.config.server.git.uri=git@github.com:xxx / Config.git

    spring.cloud.config.server.git.clone-on-start = true

    spring.cloud.config.server.git.strict-host-key-checking = false

    spring.cloud.config.server.git.skip-ssl-validation = true

  • 结果是:
    Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:519) ~[jsch-0.1.54.jar:na]
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:146) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    ... 31 common frames omitted

    为什么我的身份验证失败?

    最佳答案

    一种可能的原因是服务器以Admin而不是常规用户帐户的身份运行,这意味着它找不到%USERPROFILE%\id_rsa

    OP SledgeHammer确认in the comments:

    Jgit works against HOMEDRIVE and HOMEPATH on Windows.
    My company remaps those to a P: drive (although it doesn't remap USERPROFILE).
    And the openssh tools (and git itself) works against USERPROFILE.



    这意味着Jsch将需要 .ssh中的 P:\
    另一个原因是 format of the private key(尝试使用旧的OpenSSH格式生成的私钥进行测试)

    最后, double-check the URI used

    After investigating the jgit API, I've worked out the problem.
    The URI in the Spring Cloud Config documentation is incorrect. The documentation lists the format to be

    git@host:port/repo1.git

    It should instead be

    ssh://git@host:port/repo1.git

    So in my case, it worked once I changed it to ssh://git@mygit:2222/secops/secrets.git



    (您不需要端口2222,只需使用' /'而不是' :')

    关于github - Spring Cloud/Jgit/Github无法使用SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61484258/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com