Tony
Tony

Reputation: 473

Error : spring.cloud.config.server.git.privateKey' is not a valid private key

I am trying to get my spring cloud config sever to connect to bitbucket. But getting the following error

Binding to target org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.cloud.config.server.git' to org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties failed:

    Reason: Property 'spring.cloud.config.server.git.privateKey' is not a valid private key

Now I read that to generate the key in the correct format. I need to run the following

ssh-keygen -m PEM -t rsa -b 4096

It creates two keys a public and a private. The public

ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I added to BitBucket personal settings SSH key

The private to my yml file.

  cloud:
    config:
      server:
        git:
  #        uri: ${user.home}\dev\workdev\Fetcher\SpringCloudConfig\hp-fecher-configrepo
          uri: [email protected]:myapp/configurations.git
          default-label: main
          clone-on-start: true
          ignore-local-ssh-settings: true
          privateKey : 
                       -----BEGIN RSA PRIVATE KEY-----
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                       -----END RSA PRIVATE KEY-----

Is the problem that I generated the key on windows 10. Is the error message correct, is the key valid, but there is another error that is throwing this error.

Upvotes: 0

Views: 1517

Answers (2)

Tony
Tony

Reputation: 473

Also remove clone-on-start: true

cloud:
    config:
      server:
        git:
          uri: [email protected]:myapp/configurations.git
          default-label: main
          ignore-local-ssh-settings: true
          privateKey : 
                       -----BEGIN RSA PRIVATE KEY-----
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                       -----END RSA PRIVATE KEY-----

Upvotes: -1

Tony
Tony

Reputation: 473

A very basic mistake. I forgot to add a pipe |

 privateKey : |
                       -----BEGIN RSA PRIVATE KEY-----
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                       -----END RSA PRIVATE KEY-----

Upvotes: 1

Related Questions