springcloud配置ssh的问题及解决方法

作者:欧尼酱owo 时间:2023-11-03 15:48:11 

在gitee上创建springcloud仓库 

springcloud配置ssh的问题及解决方法

application.yaml(https方式)

server:
 port: 3344

spring:
 application:
   name: cloud-config-center #注册进Eureka服务器的微服务名
 cloud:
   config:
     server:
       git:
         strictHostKeyChecking: false
         uri: https://gitee.com/su-qiqaq/spingcloud-config.git #GitHub上面的git仓库名字
         force-pull: true #设置强行pull拉取
         #搜索目录
         search-paths:
           - springcloud-config
     #读取分支
     label: master

eureka:
 client:
   service-url:
     defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/

 application.yaml(ssh方式)

发现报错,原因是没有配置私钥在yaml中

com.jcraft.jsch.jschexception: reject hostkey:github.com

如果以前在gitee中配置了公钥,就可以在C:\Users\用户名\.ssh的id_rsa文件获取私钥,添加在yaml中

server:
 port: 3344

spring:
 application:
   name: cloud-config-center #注册进Eureka服务器的微服务名
 cloud:
   config:
     server:
       git:
         uri: git@gitee.com:su-qiqaq/spingcloud-config.git
         strictHostKeyChecking: false
         privateKey: |
           -----BEGIN OPENSSH PRIVATE KEY-----
           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
           -----END OPENSSH PRIVATE KEY-----
         # uri: https://gitee.com/su-qiqaq/spingcloud-config.git #GitHub上面的git仓库名字
         force-pull: true #设置强行pull拉取
         #搜索目录
         search-paths:
           - springcloud-config
     #读取分支
     label: master

eureka:
 client:
   service-url:
     defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/

出现错误

Auth fail

原因:

仔细查看后发现我的私钥是以BEGIN OPENSSH PRIVATE KEY开头,END OPENSSH PRIVATE KEY结尾,而

现在服务端如mysql,gitee等还不支持这种格式,因此我们还是生成原来的格式:以BEGIN RSA PRIVATE KEY开头,

END RSA PRIVATE KEY结尾。

解决:进入 git bash重新生成私钥和公钥:

ssh-keygen -m PEM -t rsa -b 4096 -C "1141793961@qq.com"

springcloud配置ssh的问题及解决方法

同样,重新在C:\Users\用户名\.ssh的id_rsa文件获取私钥,添加在yaml中,并且

重新在C:\Users\用户名\.ssh的id_rsa.pub文件获取公钥,添加在gitee的ssh公钥中

springcloud配置ssh的问题及解决方法

server:
 port: 3344

spring:
 application:
   name: cloud-config-center #注册进Eureka服务器的微服务名
 cloud:
   config:
     server:
       git:
         uri: git@gitee.com:su-qiqaq/spingcloud-config.git
         ignoreLocalSshSettings: true
         strictHostKeyChecking: false
         privateKey: |
           -----BEGIN RSA PRIVATE KEY-----
           MIIJJwIBAAKCAgEAqEh1DblLHWCzmrQpbevjWwQihOufLgglt2Lv0uT76BnOI+gi
           8YzQjgNSOPDSN6gjwiBayLqkD/cAJZeCOMj5PJyZIs9HXs/V9vUHoZRtYR7z+k0+
           QZLJDtJWB9QNCoEwbpzMCwNisuKCW3tktvTVtV9Yq1+EB6RvseRWZbf1wJbVv16T
           R0u9oYq1eaVflH0nuT/CJSi/uGO81rglGirgqwwOJSmz8MxDxp24HMuQRDK+xtXe
           8pBmvtEKirnWcB0NBWmQDd5OljpFhrLBT71YMHKvFvBtcMfpgfgdvrkvZcqlhTiO
           tAAYnsannHDF+y1L2pa76gFmPgi0HNIj4PfHc29H9d1XdH/0vzeMr6KeMhiwRBO9
           pUYcILI2/+Q5774+Be398tSx6czJoNbrzvTj1OzvYZ8Qu80LRPWlNBfzuRTF2tLv
           ummsnisrY0ii/i7FYL5RdheLvGov3qTudNRPwvFUvXG/fqFrq0QZMr9RahO8JPo0
           lViwCYc5oOLVr4xrajqz4pKXacfj7Q4M5W6lAUgDTFmNs7OhN1g9RueBe2H8tOqv
           J3rvcvCsVguSUv0sURlCnSn1YzPyf4D7vBiW+tOD+zXJ390S6vKnA20g0ZDUTNtQ
           RjAlF9sfvQpECY/zlq4JSe0EYJJbfdomKHDJyC3g6cyCh+OxIJsYPfivIh0CAwEA
           AQKCAgAXoDyW1anfEQGGOb8LSK/dymHSSYZKnyg0a/aBpFZdiqnvTpsBUKTDG2JC
           zkSlPbzvdz1nqxR3jVT+8ht9P3IGeXHiejlp7UH77wDIRZ9poD/ep1OTPzltFEix
           xqqiC+sxzF+1OB92P+jPUS6dpRgP47f+L2XI8OQhlI4wr7gX9tVBjdSdkNupv2Cl
           GHunzD50eqgWMXdhOtd7SdUjrFtoiEPAIe+6YeMuElyT5lx1xq4UGli3s2BJb+3L
           9jVN/jYiyWRJHinoW3wBYj1TpaCpBKDiVpT23YpCDgSXD0bBQsckQgF+8fiC6h8E
           Dq0tC3n30WvGebXSBcTLuxEAd6kPqIrE6lt6Jt2aBBCZ7GIU45KzsMrhQG+Uivpq
           P28ZS1+W7u/M44lcLoHpPvfA2DCEvrW/9NBcIN/C+ZbjQ5OL0E6PNJJbOuMjXMxf
           32pcGLGoDzpvKAKR907sCF6nuLDxiv1ZJr8kK+uvU3Ei7NZd6JIttT0GQtcFJQed
           Qapj5r0W6NrfygL1Vywv0XYwfvzUJ8rT56+VCC6odmbm5srwKFrfwqHBEC7ngjds
           itUJTh2TvOUqOazAYm2yveRRC3PaliivBCxGXl9ZsAdPX1oTeVQ8kJXSlHQkCBkr
           GJ6PT3s7XDxnTu5FlrqB2KmD3EiuWSEXd7KREJIo7i5IS * AQKCAQEA0N5oiq46
           CqrhpMRyP0XuBcXc8tAk/uziu+hHxykSftiSgHYuh4ELQ0X4AXFYyz1qh5Ttzxjq
           0PS0aUcfzkEp8Wpfq4DBDDN1Raq4Bqz3ML2X7W3AUDHYsmZC7trak/wJAYs29gts
           1AawRdSfcqvZPaYYqHQ46zBLW7RZ/3sEQ9Pi/luJnBUIyCUKCrzVThMjfm4Sd0/m
           Cm7UD3KjbKFfoNoaa3CNqRN+U8JSQFqREKyIkjya9fGyz9xAznBqpMyvAQoMwaFT
           l3qalS6/NgBZC29JtONs6jhT3fLZbrL/hNTUce494OIR5bHWXTndPlY5TTk68GIT
           1IKORj1bBrxJ3QKCAQEAzkGOvQSHi9wiePkY8Lawl+vXoZ8RD3zJFvkS0igThG20
           r6U1XXXg2aRi49znoHHGtNudyBz2NJmPUHfgFDLzo5x9Q9NBALNxLr1/1Op+i+g2
           TY0H0QqJ76/rBtPpu2z0j8z4sbpGv3WHPupyPw+bRYr7DrSM1/hUFEuJPQKJpFMm
           IoDlRx6muE8mTIPXx9U/9S6fgdIp7cLwQxsCz28l7fUNzz/VZAPARj9Fehj0HMaD
           fDsXdubVuXk8EM6fuZniCd1PgSvmQu6JMnSVKXsmp4OCY9Hlwg0jXBohhRhYQL94
           GePNmmeu/3YjRKB9OoFI/cYFepshwT5HFqMBOyJVQQKCAQA3cRHm3eBiPIGwrsR0
           rydDOQYxHbb0RATbRAjpgKl8KhiZKMWpCkPnE4eFOoULTb4dRxboxgBufsX0vABh
           S0LK5iWG7KJRjscuOuamPvtOYMUXLO7DWrfegu55YHZsmZX6Zu2r2dSFY1Ee+BVq
           5tq/VnttG4yQQT1/lhvdiNXU+0VhpwKb/6lZFxvXRdCI7OObB7S3Huo9ErYPc6qV
           hzBPDhW9Nx8jJh1+NjKHCoM/Hc0SpCut5P5F1n0NTyG/pOU/LV+9dgkuSEkIGGSA
           /Q6lzmCON2ANu+3nGDNHAxR4OdY6d7bNHrUJd28jR9zGUzTanrpaXG5PFmiVlGu5
           GfmxAoIBACKtvR0kxNGMKrOiVkIqxVhVzASdpRWwinL1X+e720Q52dZqdaWIK00M
           qZ/cRYmhd6JzBn1d+Ttw0jraXO+ofXR13E3qGBTRFuef7v1SjAJkAbVaUAUiu3x0
           XJTiTns334rKEMp5ImoQjbPTYXAe5KF1s66ORtwNIb3j0WhTo+bgIBpPB73Edo2o
           qSzWQhKUVVOZCjKernQOga0Wvos4Ce2PdUnyVqOhSdPF0Z2s0maALh1WJiTUvPyZ
           WLMOuqZPLEUyU6rJQcbhKmo0VdwKm74wi1zTLslIwjg7IIWrSTNhvgTEW45pfm/v
           YhCo10Vd9XLNt6Acszk1imhQ8eUKacECggEAB/ZcUrw0/RvDzYWB+e/L0dFuIFuG
           oPAm23/UayIENEniIgSeEPR2XnfJQLEjLu9RMEZ5Wn9FWICjqhZJVpNwVhPDFCEZ
           zW2On5U50EtmHTLZ7KxgR4w9YR9uqaB9cuOXTU1imO7Cs6envJ0iO6pWEFQa531Y
           XafOgOoIlZ54N/qJhS6PcYBwmgtKCl2v9PzxOJSdQRxQriTW+/EtFeqXhjcdQw4K
           UtbkGcqbg0woJkis0XnDt5tCddmATvtdngzb+9Rn+3B0i1r2ksU5/SaU1wdEmBmb
           WAsX8ey+pGxKaMPm+88FeE8glVcJ6BxFTmvng1PImOazvvZAAhvhObZO4A==
           -----END RSA PRIVATE KEY-----
         # uri: https://gitee.com/su-qiqaq/spingcloud-config.git #GitHub上面的git仓库名字
         force-pull: true #设置强行pull拉取
         #搜索目录
         search-paths:
           - springcloud-config
     #读取分支
     label: master

eureka:
 client:
   service-url:
     defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/

参考文章:

https://blog.csdn.net/u011863024/article/details/114298282

来源:https://blog.csdn.net/weixin_45974277/article/details/123362636

标签:springcloud,ssh
0
投稿

猜你喜欢

  • MyBatis-Plus逻辑删除和字段自动填充的实现

    2023-01-08 03:45:54
  • Android开发之开发者头条(二)实现左滑菜单

    2022-02-28 11:18:31
  • Spring Cloud 的 Hystrix.功能及实践详解

    2023-11-19 06:40:46
  • Spring依赖注入(DI)两种方式的示例详解

    2021-09-14 12:00:20
  • Spring boot2X Consul如何使用Feign实现服务调用

    2022-04-29 14:41:18
  • 基于Java语言MD5加密Base64转换方法

    2023-11-24 00:22:41
  • MultipartFile中transferTo(File file)的路径问题及解决

    2023-11-12 00:07:08
  • 一文详解C++模板和泛型编程

    2022-12-28 09:40:46
  • springboot整合solr的方法详解

    2023-01-20 17:54:37
  • Android实现老虎机小游戏代码示例

    2022-08-04 04:15:11
  • Java里的static在Kotlin里如何实现

    2023-08-24 20:25:33
  • GraalVM和Spring Native尝鲜一步步让Springboot启动飞起来66ms完成启动

    2023-07-19 10:34:35
  • 深入理解Java设计模式之备忘录模式

    2023-09-20 06:16:43
  • SpringMVC源码解读之 HandlerMapping - AbstractDetectingUrlHandlerMapping系列初始化

    2023-02-12 16:14:21
  • Java中线程休眠编程实例

    2021-09-06 11:42:55
  • Java Collection集合iterator方法解析

    2022-11-17 06:43:29
  • idea使用外置tomcat配置springboot详细步骤

    2023-11-20 03:56:49
  • SpringCloud 微服务最佳开发实践

    2022-02-06 10:07:45
  • Java中的collection集合类型总结

    2023-04-17 17:31:43
  • Android开发之删除项目缓存的方法

    2021-07-22 17:15:45
  • asp之家 软件编程 m.aspxhome.com