title: How do I connect to Bitbucket using SSH from a spring-config-server application?
body: <p>I have created a simple Spring cloud config server application and corresponding 'client' application. The config server reads config files from a git repo and the client app pulls them from the config server. It works with config files stored in a local git repo. I now want to connect to a remote Bitbucket server.</p>
  
  <p>I have seen a few examples using username and password hardcoded, but I don't want to hardcode these. I'd like to use SSH keys.</p>
  
  <p>I have found <a href="https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#_git_ssh_configuration_using_properties" rel="nofollow noreferrer">this example of using ssh keys</a> in the docs.</p>
  
  <p>I have a public key added to my repo in Bitbucket and i have the following application.yml file:</p>
  
  <pre><code>server:
    port: 8888
  spring:
    cloud:
      config:
        server:
          git:
            uri: git@mybitbucketserver/ubp/config-server.git
            cloneOnStart: true
            ignoreLocalSshSettings: true
            hostKey: publicKeyLabel
            hostKeyAlgorithm: ssh-rsa
            privateKey: "-----BEGIN RSA PRIVATE KEY-----MIIEoAIBAAKmJyC-----END RSA PRIVATE KEY-----"
  </code></pre>
  
  <p>Where publicKeyLabel is the name of the label added to the repo on bitbucket. When I run this config server application i get the following error:</p>
  
  <pre><code>org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin
  </code></pre>
  
  <p>With a nested error of:</p>
  
  <pre><code>Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: git@mybitbucketserver/ubp/config-server.git: not found.
  </code></pre>
  
  <p>I have double checked url. The public key attached to the repo has worked with the private key in my code in connecting from Openshift so i know it works (i have remove some of the key for this example).</p>
  
  <p>Any suggestions of what i can try? Seen so few examples of people using SSH for this, everyone seems to hardcode the PW :|</p>
  
  <p>If there is a better way of doing this I am all ears? My end goal would ideally be not to have the private key etc in code as well but I was hoping to get this working first then figure out where I can store the PK.</p>