Robert Basic's blog

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

by Robert Basic 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, keys, setup, ssh.
Categories: Development.

Need help on your PHP projects? Let's talk!