2016-10-10 18 views
2

私はLinux(arch)上で、tutorialプライベートbitbucket gitリポジトリとssh鍵を使用してSpring Cloud Configを設定しようとしていますが、エラーは続ける:Spring Cloud Configはssh鍵を使用してプライベートbitbucketリポジトリを複製できません

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: Auth fail 

さて、チュートリアルによると、それが動作するはずです:

If you don’t use HTTPS and user credentials, SSH should also work out of the box when you store keys in the default directories (~/.ssh) and the uri points to an SSH location, e.g. "[email protected]:configuration/cloud-configuration". It is important that all keys in ~/.ssh/known_hosts are in "ssh-rsa" format. The new "ecdsa-sha2-nistp256" format is NOT supported. The repository is accessed using JGit, so any documentation you find on that should be applicable. HTTPS proxy settings can be set in ~/.git/config or in the same way as for any other JVM process via system properties (-Dhttps.proxyHost and -Dhttps.proxyPort).

私はビットバケット-RSAという名前の〜/ .sshフォルダ内の秘密SSHキーを持っているが、コマンドssh-keygen -t rsa -b 4096 -C "[email protected]"を使用して作成しました。公開鍵はBitbucketに正しく追加されました。私は、コマンドラインからリポジトリから複製、プル、プッシュすることができます。秘密鍵はssh-agentに追加され、bitbucket.orgはknown_hostsファイルに存在します。

は、ここで設定・サービス事業におけるbootstrap.ymlです:ユーザー名とパスワード作品でHTTPSを使用して

spring: 
    application: 
    name: config-service 
    cloud: 
    config: 
     server: 
     git: 
      uri: "[email protected]:TarekSaid/my-private-repo.git" 
server: 
    port: 8888 

が、私はまだ、私はそれがどのように動作するかを作ることができ、SSHキーを使用して好みますか?

答えて

6

最終的には機能しました!

この質問:How to use a custom ssh key location with Spring Cloud Configは正しい方向に私を指摘しました。私はJschConfigSessionFactoryクラスをデバッグし、ユーザ名とパスワードが提供されていないときには、デフォルト設定ファイル~/.ssh/configから設定を取得することを発見しました。今では働いて

の〜/ .ssh/configに

Host bitbucket.org 
    User TarekSaid 
    Hostname bitbucket.org 
    PreferredAuthentications publickey 
    IdentitiesOnly yes 
    IdentityFile ~/.ssh/bitbucket_rsa 

はそのため、私がしなければならなかったすべては私のの〜/ .ssh/configにファイルに以下を追加しました。

関連する問題