I am trying to integrate config server with BitBucket and I am using below properties.
spring.cloud.config.server.git.uri={ssh URL of git repository } spring.cloud.config.server.git.ignoreLocalSshSettings=false spring.cloud.config.server.git.privateKey=| -----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
but I am getting error as below:
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
why I am getting this error? Am I missing any other properties over here?
same code working fine when I am pointing to local git repository.
Comment From: aattila
I have exactly the same situation
Comment From: aattila
Solved in other way. The non-working key vas generated with ssh-keygen on my Mac (10.14.5) so I used a raspberry pi to generate a new key and that is worked. It seems the problem is around the SSH versions.
Comment From: spencergibb
@dilipsingh1306 could it be something similar? Can you provide the full exception?
Comment From: DilipItAcademy
when we are passing private key property value as mentioned in below inside properties file, I have got this error always.
spring.cloud.config.server.git.privateKey=| -----BEGIN RSA PRIVATE KEY----- ---- key content -- -----key content -- -----END RSA PRIVATE KEY-----
The above format works fine with .yml file format but not with .properties file configuration.
I have resolved this issue after debugging JGit api, we should append "\n" for each line of key like shown in below when we are proceeding with properties file configuration.
When we are using .yml file with above-mentioned format, finally they are also appending newline character "\n" so applied same format for properties file directly and then it's started working fine.
spring.cloud.config.server.git.privateKey= -----BEGIN RSA PRIVATE KEY-----\n ---- key content --\n -----key content --\n -----END RSA PRIVATE KEY-----
After only this change, Error got resolved.
Comment From: introtj
JGit requires RSA keys in PEM format. Below is an example ssh-keygen (from openssh) command that will generate a key in the corect format:
ssh-keygen -m PEM -t rsa -b 4096
Comment From: emvidi
spring.cloud.config.server.git.private-key= \
-----BEGIN RSA PRIVATE KEY-----\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
your_key_here_your_key_here_you\n\
-----END RSA PRIVATE KEY-----\n
**Comment From: AnthonyCavanagh**
is it still ssh-keygen -m PEM -t rsa -b 4096 on windows 10. Because I generated that key and still getting privateKey' is not a valid private key
I am using a yml file
ignore-local-ssh-settings: true
privateKey :
-----BEGIN RSA PRIVATE KEY-----
**Comment From: emvidi**
For yml I think is something like this:
private-key: | -----BEGIN RSA PRIVATE KEY----- your_key_here_your_key_here_you your_key_here_your_key_here_you -----END RSA PRIVATE KEY----- ```
Comment From: henrysalo
If you're using yml should be replacing line breaks with /n
Comment From: MaxiCattaneoCvetic
Hi, I have the same issue. I tried to add '\n' in each line, but it doesn't work. Do you have any other solution? (im using application.properties)