Ben Ripkens

back to blog index

Storing Mercurial repository passwords in a secure manner

To store passwords permanently for Mercurial repositories  you have two options. One possibility is to store it as clear text in your Mercurial configuration file in ~/.hgrc. Of course you should never do that and that’s why I won’t explain how this could be done. Instead you should use a Mercurial extension which allows you to store passwords in a keyring. This blog post summarizes how this can be done.

At first download this file and save it somewhere, e.g. ~/.hg/mercurial_keyring.py. As a next step open ~/.hgrc (create the file if it doesn’t already exist) and add the following lines.

[extensions]
hgext.mercurial_keyring = ~/.hg/mercurial_keyring.py

Make sure to change the path to the actual location of the file which you just downloaded. Now you just have to install the following dependencies and you are done.

sudo apt-get install python-pip python-dev build-essential
sudo pip install keyring mercurial_keyring

Next time you push / pull something you should be asked for the last time for your password. If you run into any troubles you should consult this wiki page.

That's me, Ben.
Hey, I am Ben Ripkens (bripkens) and this is my blog. I live in Düsseldorf (Germany) and I am employed by the codecentric AG as a Software Engineer. Web application frontends are my main area of expertise, but you may also find some other interesting articles on this blog.