Config server with private git repository

Viewed 1288

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?

1 Answers

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

Related