Search code examples
springspring-bootbitbucketssh-keysspring-cloud-config

Spring Cloud Config using Bitbucket - SSH keys


I'm facing an error when I try to authenticate in Bitbucket using SSH private key to get my application.properties.

org.eclipse.jgit.api.errors.TransportException: https://companyuser@bitbucket.org/repositorios/cup-configuration-files: not authorized

Steps:

1) I've generated the key pair using ssh-keygen with a password

~/Development/ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ainacio/.ssh/id_rsa):

2) I've copied the key.pub to Bitbucket

Bitbucket - User - Personal Settings - Add key

3) I've configured in bootstrap.properties the private key

spring.cloud.config.server.git.uri=https://companyuser@bitbucket.org/repositorios/cup-configuration-files
spring.cloud.config.server.git.ignoreLocalSshSettings=true
spring.cloud.config.server.git.passphrase=password
spring.cloud.config.server.git.privateKey=-----BEGIN OPENSSH PRIVATE KEY-----\n
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABD4Kfq1XF
NpUPV+q/U7OPwhAAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQDuPOdeTNts
gLWlN7hLM7h+R9W76HjzrJ6pNHFVq8htKaQodmGuNFrna1y6k88FMds4XAJIv8rB2C2TyD
Y+eVKsKCfQ7xSoP/3NwOegRmvVYVUETvDJrop2Cmi4DnM6QlrtDum+VicEKjtQD7sOJ85R
WJpHkf/+CIZW8cbwdaMAjtr9LE6t+4lOg15Xfyu9zFI4YBpxb3C08/x4CS0bdiWX73Z+uT
AQWfGSbcxXleFHCDv0xCvE6/uMt2rTsnuFfLNTannEwzIYLV//0eMesQywzN+D3gxPZKeG
P1E54xXVjewsW74GJhmnI5Tm5DvsXvvQ5bkELH+isPrH9sZbncPFq9e6qjA88gk2BCLEe/
E5jdL0OKrIGFJjwpN8T/sDfq3SvuLIPvOsLlZXw0yUDgTvJdLKdwSFFB7WPKZqINXBSmKr
PUKZMm3WBB4gLccU+vD/1uardrMZ5lj0hJp7YRukWfXCFvZYLs0lnM2xnTuFsKNOfxOKDv
....

What is missing? I tried to find some tutorials but I couldn't.

PS: I'm in development environment. Accptance and production I'll use the file on .ssh server directory.


Solution

  • It needs to use RSA encryption algorithm ssh-keygen -m PEM -t rsa -b 4096 -C 'bitbucket_username'