Configuring read-only and read-write access to bitbucket repos

published on January 30, 2015.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

Trying to automate things on my server, I ended up needing read-only for one group of my bitbucket repos and read-write access to another group.

On bitbucket, if read-only access is required for a repository, a deployment key can be added for that repository.

Create one ssh key that will be a deployment, read-only key:

user@server$ ssh-keygen -f ~/.ssh/id_rsa_ro -t rsa -C ""

and add it to repositories needing read-only access.

Create a second ssh key that will be used for repositories needing read and write access:

user@server$ ssh-keygen -f ~/.ssh/id_rsa_rw -t rsa -C ""

and add it as an ssh key under your bitbucket account.

Next, configure ssh a bit, telling it what identity to use for what host by adding something like this to the ~/.ssh/config file:

    IdentityFile ~/.ssh/id_rsa_ro

    IdentityFile ~/.ssh/id_rsa_rw

With all that in place, for repositories where read-only access is needed, set the remote url for the origin like:

git remote set-url origin

and where read-write access is needed:

git remote set-url origin

Now for repositories with the hostname I have read-only access and for repositories with the hostname read and write access. Neat.

Tags: bitbucket, ssh, keys, setup.
Categories: Development.

Thanks for reading! If you require help on a project of any kind, let's talk!

Robert Basic

Robert Basic

Software engineer, consultant, open source contributor.

Let's work together!

If you require outsourcing or consulting help on your projects, I'm available!

Robert Basic © 2008 — 2019
Get the feed