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?

suru1432002
  • 143
  • 2
  • 8

6 Answers6

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.

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
JEWEL AHMMED
  • 125
  • 1
  • 3
  • 11
1

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

H23
  • 11
  • 1
1

March 2022

Looks like BitBucket user interface changed again.

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

George
  • 2,436
  • 4
  • 15
  • 30
  • That is for personal accounts, life happens... – bbaassssiiee Jun 09 '22 at 12:17
  • 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. – George Jun 09 '22 at 14:10
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.

ykembayev
  • 108
  • 1
  • 8
  • This is not about my account. I need to upload the key Under Deployment Key for every repository – suru1432002 Dec 29 '16 at 08:44
  • 1
    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. – suru1432002 Dec 29 '16 at 08:48
  • @suru1432002 suggest[jenkins] (https://jenkins.io/), but i am not sure, i understand you correctly – ykembayev Dec 29 '16 at 09:27
  • 1
    Not sure I understand either. As @ykembayev 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. – Erik van Zijst Dec 30 '16 at 04:03
  • I thought so but if I add a key to the use generic seetings page: https://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? – Riccardo Mar 12 '17 at 10:44
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
bbaassssiiee
  • 6,013
  • 2
  • 42
  • 55
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