spring config server git ssh unknownhostkey

时间:2016-06-02 15:10:57

标签: spring ssh

我部署了Spring云配置服务器,通过ssh连接到git存储库。

spring:
  cloud:
    config:
      server:
        git:
          uri: ssh://git@stash.ops.domain.com:2022/ccare/cm-config-data.git
          searchPaths: [preferences, orders]

我已将ssh密钥(id_rsa.pub)添加到Git stash。 我还添加了带有StrictHostKeyChecking的/.ssh/config文件没有选项。 但是当我访问配置服务器时,我仍然会收到此错误。

[nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Cannot clone or checkout repository] with root cause

com.jcraft.jsch.JSchException:UnknownHostKey:stash.ops.domain.com。 RSA密钥指纹为39:89:4b:aa:79:fc:01:9f:46:48:5b:b9:6f:17:af:d5         在com.jcraft.jsch.Session.checkHost(Session.java:786)         在com.jcraft.jsch.Session.connect(Session.java:342)         在org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)         在org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)         在org.eclipse.jgit.transport.TransportGitSsh $ SshFetchConnection。(TransportGitSsh.java:262)         at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)         at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)         在org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)         在org.eclipse.jgit.transport.Transport.fetch(Transport.java:1115)         在org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)         在org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)         在org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)         在org.springframework.cloud.config.server.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:265)         在org.springframework.cloud.config.server.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:237)

1 个答案:

答案 0 :(得分:0)

我遇到了确切的问题。我提出的解决方案(我使用过)是一个黑客但是对我有用。只需ssh该服务器

ssh stash.ops.domain.com

您将收到以下提示:

The authenticity of host 'stash.ops.domain.com' can't be established.
RSA key fingerprint is <fingerprint>
Are you sure you want to continue connecting (yes/no)?

如果您说yes,那么stash.ops.domain.com将添加到known_hosts。 添加完成后,您将不再收到该错误。