Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.0.RC3 can not use local ssh settings #1251

Closed
seelikes opened this issue Feb 15, 2019 · 19 comments
Closed

2.1.0.RC3 can not use local ssh settings #1251

seelikes opened this issue Feb 15, 2019 · 19 comments

Comments

@seelikes
Copy link

you may see the issue here too, i post it there first.

actually i have test 2.0.1.RELEASE 2.1.0.RC3. for more details, spring boot version 2.0.5 2.1.0 2.1.1 2.1.2
with 2.0.1.RELEASE, you can config git config server like below

 spring.cloud.config.server.git.uri=ssh://username@gerrit-server/project
 spring.cloud.config.server.git.search-paths=/path
 spring.cloud.config.label=master

but others, this does not work.
i'd like to consider this a bug of jgit, but i changed jgit manually from 5.1.3.201810200350-r to 4.11.0.201803080745-r, which is the version used by sb 2.0.1.RELEASE, still does not work, and the error is the same.
and 5.2.1.201812262042-r also the same.
and i guarantee that there is everything you need to clone a project below user's home. git clone in the command line worked vast well.
and my computer is windows 10, jdk 1.8.0_201
and the exception is below:

org.eclipse.jgit.api.errors.TransportException: ssh://username@gerrit-server/project: Auth fail
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:574) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:549) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.createGitClient(JGitEnvironmentRepository.java:532) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:261) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.getLocations(JGitEnvironmentRepository.java:240) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.getLocations(MultipleJGitEnvironmentRepository.java:150) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:47) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:190) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:46) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.cloud.config.server.config.ConfigServerHealthIndicator.doHealthCheck(ConfigServerHealthIndicator.java:55) [spring-cloud-config-server-2.1.0.RC3.jar:2.1.0.RC3]
    at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:84) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:98) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:50) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:246) [spring-core-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:76) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:61) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:126) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:99) [spring-boot-actuator-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_201]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_201]
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_201]
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_201]
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_201]
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_201]
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_201]
    at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_201]
    at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_201]
    at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_201]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_201]
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_201]
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_201]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) [na:1.8.0_201]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_201]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_201]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_201]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_201]
Caused by: org.eclipse.jgit.errors.TransportException: ssh://username@gerrit-server/project: Auth fail
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:192) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:137) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1271) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:243) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    ... 47 common frames omitted
Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:519) ~[jsch-0.1.54.jar:na]
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:146) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    ... 54 common frames omitted
@ryanjbaxter
Copy link
Contributor

Please use Greenwich.RELEASE and try again. If you can reproduce the problem with Greenwich.RELEASE can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

@seelikes
Copy link
Author

@ryanjbaxter i'm sorry, what is Greenwich.RELEASE, do you mean 2.1.0.RELEASE?
i tried the newest spring boot, 2.2.0.BUILD-SNAPSHOT, which has the same error. and you can see my demo from the attachment.
you may need to change the spring.cloud.config.server.git.uri property since this is my own code server, and you can never auth success.
sb-config-demo-2057.zip

@ryanjbaxter
Copy link
Contributor

I started this git server locally https://hub.docker.com/r/jkarlos/git-server-docker/
and changed spring.cloud.config.server.git.uri to point to it and everything worked fine using your sample

@seelikes
Copy link
Author

@ryanjbaxter is it possible that this git server does not need local ssh settings? could you change the spring.cloud.config.server.git.uri to this project, since i have already tested github, and it's the same error.
and my system is windows 10, is it possible that the problem happens only on windows 10 system? i will test ubuntu on Monday,on my work computer.

@seelikes
Copy link
Author

@ryanjbaxter i have tested my demo on Ubuntu, everything worked well.
and i re-test this demo on windows 10, yet still this error.
is it possible this is an error about system? why spring boot 2.0.5 with spring cloud config 2.0.1 worked fine?
i hava also test spring boot 2.0.5 on Ubuntu, worked well.

@ryanjbaxter
Copy link
Contributor

Could it be something with ssh on windows? I cant really say, no one on the team uses Windows so we cannot test.

@ryanjbaxter
Copy link
Contributor

In any case it does not sounds like this is a problem with Spring Cloud Config since we dont have any OS specific code. It could be something with JGIT I suppose.

@ryanjbaxter
Copy link
Contributor

Did you use the same JDK on Ubuntu?

@ryanjbaxter
Copy link
Contributor

Maybe use JGIT directly without Spring Cloud and see if you get a similar issue?

@seelikes
Copy link
Author

@ryanjbaxter i think you're right, maybe this really has nothing to do with spring-cloud-config. could you please mark this issue as help-wanted, maybe someone will come with an solution someday? if not, you can close this issue anyway, thanks.

@ryanjbaxter
Copy link
Contributor

I will close it, if someone else finds the issue they can comment and we can try to address it

@Bryksin
Copy link

Bryksin commented Oct 30, 2019

Facing the same issue
Environment:
Mac "Catalina"
OpenJdk: 11
Spring Boot: 2.2.0.RELEASE
springCloudVersion: Hoxton.RC1 || Greenwich.RELEASE - doesn't matter, the problem exists in both

Bootstrap.yml:

---
spring:
  profiles: dev
  cloud:
    config:
      server:
        git:
          uri: git@<some_our_domain>/spring-config-dev.git
          ignoreLocalSshSettings: false

Exception:

org.eclipse.jgit.api.errors.TransportException: git@<some_our_domain>/spring-config-dev.git: Auth fail
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:574) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:549) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.createGitClient(JGitEnvironmentRepository.java:532) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:261) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.getLocations(JGitEnvironmentRepository.java:240) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.getLocations(MultipleJGitEnvironmentRepository.java:149) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:47) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:189) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:46) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.config.server.config.ConfigServerHealthIndicator.doHealthCheck(ConfigServerHealthIndicator.java:55) ~[spring-cloud-config-server-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:80) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:38) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:106) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:116) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:103) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:81) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:68) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:74) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:279) ~[spring-core-5.2.0.RELEASE.jar:5.2.0.RELEASE]
	at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:77) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809) ~[na:na]
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) ~[na:na]
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) ~[na:na]
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) ~[na:na]
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399) ~[na:na]
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) ~[na:na]
	at java.base/jdk.internal.reflect.GeneratedMethodAccessor77.invoke(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) ~[na:na]
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) ~[na:na]
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) ~[na:na]
	at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[na:na]
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[na:na]
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[na:na]
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) ~[na:na]
	at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.eclipse.jgit.errors.TransportException: git@<some_our_domain>/spring-config-dev.git: Auth fail
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:192) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:137) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1271) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:243) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	... 54 common frames omitted
Caused by: com.jcraft.jsch.JSchException: Auth fail
	at com.jcraft.jsch.Session.connect(Session.java:519) ~[jsch-0.1.54.jar:na]
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:146) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
	... 61 common frames omitted

@ryanjbaxter any idea?

@Bryksin
Copy link

Bryksin commented Oct 30, 2019

Got it sorted!

  1. basically I had to create ~/.ssh/config file, without it, JSch didn't work at all, even though git itself working just fine without it.
Host <your_git_host>
    HostName <your_git_host>
    IdentityFile ~/.ssh/<your_git_service/bot_user_private_key-id_rsa>

only when you will directly point it to identityFile, only then it will attempt to use your private key.
However, it might also fail with another error:

Caused by: com.jcraft.jsch.JSchException: invalid privatekey

even though the key is definitely valid, in that case, you may help 2nd step:

  1. Since OpenSSH 7.8 and higher default private key format starts with:

-----BEGIN OPENSSH PRIVATE KEY-----

where JSch doesn't support it, and key needs to be converted to old RSA format:
-----BEGIN RSA PRIVATE KEY-----

here is the command:

ssh-keygen -p -f <your_git_service/bot_user_private_key-id_rsa> -m pem -P passphrase -N passphrase

@SledgeHammer01
Copy link

@Bryksin I'm having the same issue and tried your fix and still getting auth failed.

My config file looks like:

Host github.com
	HostName github.com
	IdentityFile ~/.ssh/id_rsa

And my application.properties looks like:

spring.cloud.config.server.git.uri=git@github.com:xxx/Config.git
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.strict-host-key-checking=false
spring.cloud.config.server.git.skip-ssl-validation=true
spring.cloud.config.server.git.ignore-local-ssh-settings=false

@emrekgn
Copy link

emrekgn commented Aug 18, 2021

I know this is an old issue page but the problem still exists and this is the first link that comes up on Google, so I'm just posting this for reference.

The problem is actually related to JGit and how you generate your SSH key pairs.

If you use ssh-keygen -m pem to generate using PEM format, then the private key file has a comment line beginning with -----BEGIN RSA PRIVATE KEY-----
If you just simply use ssh-keygen to generate them, it uses OpenSSH format and the private key file has a comment line beginning with -----BEGIN OPENSSH PRIVATE KEY----- and JGit library cannot recognize the OpenSSH formatted key file.

So for anyone still having this issue, the quickest solution would be to re-generate your SSH key pair using PEM format.

But according to this JGit release notes, they handled this problem on version 5.2. So if spring-cloud-config can upgrade its JGit version to at least 5.2, this should be permanently fixed.
(Correct me if I am wrong but I think it currently uses JGit 5.1.3)

Edit: This is only true if you are using an older version of spring-cloud-config-server (e.g. 3.0.4 or older or SpringBoot v2.4.x or older)

@ryanjbaxter
Copy link
Contributor

@emrekgn
Copy link

emrekgn commented Aug 18, 2021

Thanks for the clarification @ryanjbaxter. It's my bad I didn't write the SpringBoot version (v2.4.9) in the first post, so the problem is just using an older version of Spring Cloud Config.

(I'm looking at Spring Initializr) SpringBoot 2.4.x with Spring Cloud Config Server dependency comes with spring-cloud-config-server v3.0.4 which depends on JGit v5.1.3. So I think if I just use a newer version (3.1.0), it should be resolved.

Thanks again!

@PepeValenzuela98
Copy link

PepeValenzuela98 commented Jul 18, 2022

Any news? im trying the steps of @Bryksin but im strill getting the Invalid Privatekey error.

this is my yml config

git:
default-label: master
uri: git@github.com:PepeValenzuela98/config-repo.git
cloneOnStart: true
ignoreLocalSshSettings: true
passphrase: ${myPassphrase}
privateKey: ${privateKey generate of @Bryksin process}

and im getting:

Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@2625667b at com.jcraft.jsch.KeyPair.load(KeyPair.java:664) ~[jsch-0.1.55.jar:na] at com.jcraft.jsch.KeyPair.load(KeyPair.java:561) ~[jsch-0.1.55.jar:na] at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40) ~[jsch-0.1.55.jar:na] at com.jcraft.jsch.JSch.addIdentity(JSch.java:406) ~[jsch-0.1.55.jar:na] at com.jcraft.jsch.JSch.addIdentity(JSch.java:366) ~[jsch-0.1.55.jar:na] at org.eclipse.jgit.transport.JschConfigSessionFactory.getJSch(JschConfigSessionFactory.java:383) ~[org.eclipse.jgit.ssh.jsch-5.12.0.202106070339-r.jar:5.12.0.202106070339-r] at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:120) ~[org.eclipse.jgit.ssh.jsch-5.12.0.202106070339-r.jar:5.12.0.202106070339-r] ... 36 common frames omitted

@bvn13
Copy link

bvn13 commented Dec 21, 2022

@PepeValenzuela98

invalid privatekey: [B@2625667b

means that you are using OpenSSH key format. Convert the private key into old RSA format or create a new one pair.


I'm struggling with such issue. I'm on Linux.
My git server is hosted with gitea. The access is set up via ssh.
I created a key pair usin

ssh-keygen -m PEM -t rsa -b 4096 -f ~/.ssh/my_key.rsa

~/.ssh/config has these lines:

Host gitea.my.server
    HostName gitea.my.server
    IdentityFile ~/.ssh/my_key.rsa

My spring boot version is 2.6.8, spring cloud version is 2021.0.1 and jgit is up to 5.9.0.202009080501-r (the latest 5.x version at the moment).

My config is

spring:
  cloud:
    config:
      server:
        git:
          uri: ssh://git@gitea.my.server:2221/team/properties.git
          clone-on-start: true
          passphrase: my-phrase

And I get the exception:

Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@gitea.my.server:2221/team/properties.git: Auth fail
	at app//org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:162)
	at app//org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
	at app//org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:254)
	at app//org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:144)
	at app//org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:105)
	at app//org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:91)
	at app//org.eclipse.jgit.transport.Transport.fetch(Transport.java:1260)
	at app//org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:211)
	... 160 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
	at app//com.jcraft.jsch.Session.connect(Session.java:519)
	at app//org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:115)
	... 167 more

Last logs jgit shows are:

SSH_MSG_KEX_ECDH_INIT sent
expecting SSH_MSG_KEX_ECDH_REPLY
Host 'gitea.my.server' is known and matches the ECDSA host key
SSH_MSG_NEWKEYS sent
SSH_MSG_NEWKEYS received
SSH_MSG_SERVICE_REQUEST sent
SSH_MSG_SERVICE_ACCEPT received
Authentications that can continue: publickey,keyboard-interactive,password
Next authentication method: publickey
Disconnecting from gitea.my.server port 2221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants