简体   繁体   中英

Config server with private git repository

I want to use private git repository with my config server. Here is my application.yml :

server:
  port: 100
spring:
  application:
    name: smth-config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/smth/smth
          default-label: main
          username: smth
          password: smth
          host-key-algorithm: ssh-rsa
          ignore-local-ssh-settings: true
          host-key: ssh-rsa smth== github.com
          private-key: -----BEGIN RSA PRIVATE KEY-----
            smth
            -----END RSA PRIVATE KEY-----

I get the following error:

Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/smth/smth: not authorized
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:544)

How should I fix it?

For this to work with a private repository you must use a git access token (which you can generate following this steps ) on your password property.

so for example

server:
  port: 8888

spring:
  cloud:
    config:
      server:
        git:
          uri: yourgithubrepo 
          username: ${GIT_USER}
          password: pasteyouraccesstoken
          default-label: "main"  

that should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM