'Spring Cloud Config - Cannot clone or checkout repository: ssh://[email protected]/<user>/repo.git

When I try the URL with https it works but I don't want to have the username and password. I am able to perform a git clone with the above url and its working. But when I try it in the code and hit the localhost:8888/default endpoint I get the error:

{
"error": "Not Found",
"message": "Cannot clone or checkout repository: ssh://[email protected]/<user>/config-repo.git",
"path": "/licensingservice/default",
"status": 404,
"timestamp": "2018-04-30T23:32:54.726+0000"
}

Here is my application.yml entry

server:
  port: 8888
spring:
  cloud:
    config:
      server:
        git:
          uri: ssh://[email protected]/<user>/config-repo.git
          searchPaths: licensingservice

I am using spring cloud config - Finchley.Not. No sure what I am missing. Please suggest.



Solution 1:[1]

Few things to inspect:

  1. Do you have github in your known_hosts? If not, then it will prompt you to enter password even you have key pairs that might cause the error.
  2. Do you have SSH keys under /home/{you}/.ssh/ folder?
  3. When you generate your keys, did you use passphrase? If so, you need to include the passphrase key in your YAML file.

If all above are okay. Then download the spring-cloud-config-server, debug the org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.class

Good luck.

Solution 2:[2]

You have to add your machine's ssh key to the repo.

Ssh key should be generate with the following command: ssh-keygen -m PEM -t rsa -b 4096 -C "[email protected]"

For more info, you can check this link

https://skryvets.com/blog/2019/05/27/solved-issue-spring-cloud-config-server-private-ssh-key/

Solution 3:[3]

I also faced a similar problem with spring cloud config server. You need to add an additional property spring.cloud.config.server.git.skip-ssl-validation=true in application.properties file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Charles C.
Solution 2 makasujan
Solution 3 JJJ