Error when using Git credential helper with gnome-keyring as Sudo

I was looking for a way to store credentials securely while connecting to our Git server which uses SSL. I came across this suggestion by @james-ward (only edit I made was I updated our “system” config instead of our “global” config for Git (

sudo apt-get install libgnome-keyring-dev
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --system credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring

I then can run

  • Can gitk show the diff of merges by default?
  • Visual Studio 2013 GitHub
  • Can you use libgit2 to clone a git repository?
  • How to create a remote Git repository from a local one?
  • How to integrate a GitHub wiki into the main project
  • Ownership on github and how to unfork a repository?
  • git clone https://ipaddress/git/repo.git

    and the credential helper will store my credentials, however when I run the following:

    sudo git clone https://ipaddress/git/repo.git testfolder

    it give me the following error

    ** (process:3713): CRITICAL **: Error communicating with gnome-keyring-daemon

    I sometimes need to run sudo git clone since sometimes the directory where I need to make a clone requires it. Any help would be appreciated.

    Versions I am using:
    – git version 1.9.1
    – Ubuntu Server 14.0.4

    Thank you in advance!
    -Richard O.

  • Moving from Private GitHub Repo to Public and Private
  • Where does the default Visual Studio 2013 .gitignore reside?
  • What are the best practices for having git clean history?
  • swipe activity to change another activity in android and show multiple Activity in a singleview?
  • Why are there 2 ways to unstage a file in git?
  • Reset local repository branch to be just like remote repository HEAD
  • 3 Solutions collect form web for “Error when using Git credential helper with gnome-keyring as Sudo”

    I sometimes need to run sudo git clone since sometimes the directory where I need to make a clone requires it. Any help would be appreciated

    The folder in which you try to clone the repository into was created by root so you dont have permission to write or to create folder under it unless you are root (sudo), set the permissions (chmod or chown) and you will be able to clone into the folder.

    chmod 755 /path

    Beside the use of sudo, note that in 2016, libgnome-keyring is specific to GNOME and is now deprecated (since January 2014, actually).

    Git 2.11+ (Q4 2016) will include a new credential helper using libsecret.

    See [commit 87d1353] ( (09 Oct 2016) by Mantas Mikulėnas (grawity).
    (Merged by Junio C Hamano — gitster — in [commit bfe800c] (, 26 Oct 2016)

    A new credential helper that talks via “libsecret” with implementations of XDG Secret Service API has been added to contrib/credential/.

    it uses libsecret which can support other implementations of XDG Secret
    Service API.

    1. You can install libsecret and the development libraries with:

      sudo apt-get install libsecret-1-0 libsecret-1-dev

    2. Then you need to build the credential manager

      cd /usr/share/doc/git/contrib/credential/libsecret (copy the credential/libsecret folder from source, if it’s not installed automatically)

      sudo make

    3. Finally, you should point git to the newly created file in your config:

      git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret

    As noted by mati865 in the comments:

    It should be noted that some distros like Arch and Fedora provide helpers available as both binary and source.

    • Libsecret binary on Arch: /usr/lib/git-core/git-credential-libsecret, and
    • Libsecret binary on Fedora: /usr/libexec/git-core/git-credential-libsecret.

    Using sudo runs the command as root. It’s like asking your sysadmin, if you have one, to run a command for you. The root user is not meant to do anything development-related, and therefore git is not meant to be used as root.

    Once you run a command as another user (root or any other), it is expected that this other user cannot communicate normally with your usual user (in particular, it doesn’t find your gnome-keyring-daemon here).

    So, the answer is: “don’t do that”. If you really need to clone in a particular directory, give yourself permissions on that directory as suggested in CodeWizard’s answer. Actually, if you need to clone in a directory where you don’t have permission, ask yourself whether you are doing something wrong: in principle, this shouldn’t happen (my guess is: you already used sudo too much in the past and this is the reason why you have um-writable directories here and there).

    Git Baby is a git and github fan, let's start git clone.