One ssh-key to all repositories in bitbucket
Asked Answered
L

6

9

We have a application account in my server for which we have generated a ssh-key. We need to upload the application account public key to all the repositories in my bit-bucket project. There are so many repositories in my project we can't upload the keys manually in every repository every time we generate a new key. So Do we have any automated way to do this?

Laid answered 29/12, 2016 at 7:20 Comment(0)
B
8

If I understood your question properly. I will explain a few things about BitBucket SSH Access, After that hopefully, you will get your answer.

If you go to your main BitBucket setting, You will see SSH Keys option under the Security. Here you will able to add your SSH Public Key. In my cases I already have a RAS SSH Public key called id_ras.pub After adding this key I can access all of my BitBucket repositories using SSH from my PC whatever it's new or old repo. You are also able to add multiple SSH Key to your BitBucket account.

Screenshot: BitBucket Account SSH Keys Settings

They have another option to get read-only access called Use access keys.

In this section, You are able to add SSH Public key per-repository basis. After adding User Access Keys the key owner can access this specific repo using SSH. But They will have Read Only access only. You can use your same User Access Keys in multiple repositories. So, they will have multiple repo access using the key.

Be sure the key can't be the same key as your Main BitBucket Settings Keys You need to use another public key as your User Access Keys

Screenshot: BitBucket User Access Keys Settings

In my cases, I don't have any user access keys. You can know more about Main Account SSH Keys & User Access Key using their help link.

Bespoke answered 6/9, 2017 at 14:45 Comment(0)
B
4

March 2022

Looks like BitBucket user interface changed again.

Now SSH keys are configured at https://bitbucket.org/account/settings/ssh-keys/

Busch answered 15/3, 2022 at 19:49 Comment(2)
That is for personal accounts, life happens...Couvade
I was brought here by Google when I was looking in vain for a way to upload an ssh key to bitbucket. When I finally found the interface, I went back here and documented the URL for future users with the same problem. It is not obvious that personal accounts would have a different URL, and it is even less obvious that someone should add "personal account" to Google search terms. So, here is the answer for others who will get here via Google.Busch
A
2

I think op is asking about where to add a ssh-key that allows access to all repositories (for automated clones in pipeline etc). To best of my knowledge you do this within your workspace

https://bitbucket.org/YOURWORKSPACE/settings/ssh-keys. if you have already added that key to any of your repos under access keys it will fail though so best to make a new key, or go through all your projects and remove it then add it here

Apiarian answered 30/7, 2021 at 10:19 Comment(1)
I can't seem to get this to work. Has it changed already?Oma
Y
0

I am not sure, I understand your question correctly. In Bitbucket setting(under your profile) > "SSH keys" you can add your ssh-key for account and it should work for your all repositories.

Yaker answered 29/12, 2016 at 7:32 Comment(5)
This is not about my account. I need to upload the key Under Deployment Key for every repositoryLaid
My questions is simple. All i need is to upload the deployment key for all the repositories in my project. I can't upload the key manually everytime going to each repository setting (Deployment key). Is there any automated way to upload the Deployment key for all the repositories in my project. Thanks in Advance.Laid
@Laid suggest[jenkins] (jenkins.io), but i am not sure, i understand you correctlyYaker
Not sure I understand either. As @Yaker points out, when you upload the SSH key to the account, then you'll be able to clone all repos. No need for uploading it as a deploy key to each and every individual repo.Trinette
I thought so but if I add a key to the use generic seetings page: bitbucket.org/account/user/palladius/ssh-keys it doesn't work (tried both RSA and DSA) whereas it works perfectly if I add the key to the single repo. Am I doing possibly something wrong?Resoluble
C
0

If you use BitBucket server with a team, then it's likely your team has gotten a "projectKey", i.e. a namespace where you can add multiple Git repositories. The projectKey's value is usually the part shown in UPPERCASE in the URL.

You can configure the public SSH key for your application under "Access Keys" on each Repository's Settings, but rather use the Project Settings. These apply to all repositories under the project.

You can update ssh keys with the REST API:

/rest/keys/1.0//projects/{projectKey}/ssh
Couvade answered 9/6, 2022 at 12:16 Comment(0)
O
0

Not sure if this is what you need, but you can create a "project" and move all the repos to that project, then use the following interface to create a project-level SSH key which should work for all existing and new repos.

https://bitbucket.org/<organization>/workspace/projects/<project_key>/settings/access-keys

Oma answered 1/12, 2022 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.