Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bootstrap spring cloud config server with Private Github repository?

I need to connect spring cloud server to my private github repository. I get an error "Reason: Property 'spring.cloud.config.server.git.privateKey' is not a valid private key"

Steps:

  • First I create by git bash a public and private key.
  • Then I deploy the public key under github config repository (where i put configuration files == config-repo)
  • Finally this is my application.yml
spring:
   cloud:
    config:
      server:
        git:
          uri: [email protected]:[repository]/config-repo.git
          searchPaths: '{application}'
          hostKey: someHostKey
          hostKeyAlgorithm: ssh-rsa
          ignoreLocalSshSettings: true
          privateKey: |
                      -----BEGIN RSA PRIVATE KEY-----
                      [...]
                      -----END RSA PRIVATE KEY-----

Could you help me to startup my server ? Thanks a lot

like image 535
anthony44 Avatar asked Mar 06 '19 16:03

anthony44


3 Answers

I was facing the same ... I was generating my keys with Linux ssh-keygen

I generated keys and not more Reason: Property 'spring.cloud.config.server.git.privateKey' is not a valid private key error

like image 54
JPG Avatar answered Nov 01 '22 08:11

JPG


You need to store the key-pair in the PEM format. This was the default a while back, but these days you have to specify it when you invoke ssh-keygen.

An example:

ssh-keygen -m PEM -t rsa -b 4096 -C "[email protected]"

The private key you get out then starts with:

-----BEGIN RSA PRIVATE KEY-----
...
like image 22
rud Avatar answered Nov 01 '22 09:11

rud


I had the same problem and solved my issue with adding the passphrase (the one us) solve my issue.

spring.cloud.config.server.git.passphrase=yourPassphrase

PS: I am using .properties instead of .yml.

like image 21
evren Avatar answered Nov 01 '22 09:11

evren