Reputation: 69
Sort of stuck on above. although i see there are questions asked on same topic, and have tried them but still no resort.
stack im using -> mac(mojave), Intellij, jdk8, generated key using puttygen on mac itself and looks like this, this is only for my local springboot config server.
i have tried 2 ways: spring.cloud.config.server.git.private-key=-----BEGIN RSA PRIVATE KEY-----\n MIIEowIBAAKCAQEAssBl7ZADFHBZrSnDPVhClH9HFzCaEPKEaO3MX7H5uBMTEL59\n CLRguWdCQJnvv2L6vSLyBb9ds05DHEzE2OqkU5VzYX4CCrU7t1ktZmy3cwyNc0g0\n ijJMInd47KG57Pi6nzpN/bVsLNiwRO3PZ7wUxgeQT6vh5euhBbTlvrFRbNMZm0Rf\n .... .. ,,, F5vNwcngKk/tFFwX2XooikGliOCxHU66/KOckbNXqOaLBc+QlNsB\n -----END RSA PRIVATE KEY-----
gives error:
APPLICATION FAILED TO START
Description:
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
2) spring.cloud.config.server.git.private-key=~/.ssh/temp/id_rsa spring.cloud.config.server.git.ignore-local-ssh-settings=true
and still get the same error as i shared above.
3) there was a SO question where solution talked, that the key might not be created right. Now i have using the same key for my normal development & been using it fine for a year & have the pub added to my bitbucket repo and it works fine. its our own repo(not git hub) i normally work fine with the key in ~/.ssh/id_rsa. So i created RSA private key from ~/.ssh/id_rsa file into a temp directory and using the same for the config server APP.
4) in the known hosts file, there are about 7 entries 1 of them is the bitbucket server. and its ssh-rsa.
was wondering if there a step-by-step guide or some sample someone can help me with please ?
Upvotes: 4
Views: 12700
Reputation: 1300
Maybe this will help, user 'introtj' commented here https://github.com/spring-cloud/spring-cloud-config/issues/1392 and this helped me.
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
Update 22-Apr-2021
So today I decided to switch from yml to properties and of course had the same error as above. I knew the key was good because it was working fine in the YAML format. After 2 hours of trial and error I managed to get it working:
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
I am using spring boot 2.4.5 and spring cloud 2020.0.02
Let me know if it is working for you this solution.
Upvotes: 5
Reputation: 5968
Just add |
spring.cloud.config.server.git.private-key= |
----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA3Tz2mr7SZiAMfQyuvBjM9Oi..
RK+Lh9x5eJPo5CAZ3/ANBE0sTK0ZsDGMak2m1g7..
wnLe4nOb7/eEJbDPkk05ShhBrJGBKKxb8n104o/..
5A13wiLitEO7nco2WfyYkQzaxCw0AwzlkVHiIyC..
-----END RSA PRIVATE KEY-----
Upvotes: 1