Git 1.8.0 supports integration with gnome-keyring.
http://www.h-online.com/open/news/item/Git-1-8-0-can-access-Windows-and-GNOME-keyrings-1733879.html
After reading the docs about the git credentials helpers: http://git-scm.com/docs/gitcredentials.html
I was not able to find a way to use this new feature. How can I integrate it? I'm using Archlinux with git installed from Archlinux's repository. (git 1.8.0)
10 Answers 10
@marcosdsanchez's answer is for Arch (which answers the original question) but I'm on Ubuntu. For git >= 2.11:
sudo apt-get install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
For git < 2.11:
sudo apt-get install libgnome-keyring-dev
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
git help -a | grep credential- and see if you have other helpers installed. Ones that come by default are credential-cache (remember password for some time after you enter it, 15 minutes by default), and credential-store (just store the password in plaintext on an unencrypted file on disk, ~/.git-credentials by default).chmod 0755 git-credential-gnome-keyring to add execution permission to others than rootGit 1.8.0 comes with gnome-keyring support but the binary needs to be compiled for your platform.
This is what solved it for me in Archlinux:
$ sudo pacman -S libgnome-keyring
$ cd /usr/share/git/credential/gnome-keyring
$ make
$ git config --global credential.helper /usr/share/git/credential/gnome-keyring/git-credential-gnome-keyring
@VonC solution was close, but the git config command should point to the executable. That's why it was not working for me.
Package gnome-keyring-1 was not found in the pkg-config search path. you are missing the dev libraries for gnome-keyring. On Ubuntu these are available with apt-get install libgnome-keyring-dev. Also, I had to download the git contrib repo manually from github.com/git/git/tree/master/contrib and put it in /usr/share/git-core/. These files are no longer included with a default git install, at least using the official git-core ubuntu ppa.git-credential-gnomekeyring is gone, too bad that in AUR there's no such information.libgnome-keyring is sufficient (at least if you are using gnome).libgnome-keyring is now deprecated and requires one of the org.freedesktop.secrets packages to be installed. Of which the new gnome-keyring is one.Update Q4 2016:
Unix, Mac (Git 2.11+)
git config --global credential.helper libsecret
(See "Error when using Git credential helper with gnome-keyring")
Windows:
git config --global credential.helper manager
(See "How to sign out in Git Bash console in Windows?": That is Git for Windows using the latest Microsoft Git Credential Manager for Windows)
Reminder: libgnome-keyring is specific to GNOME and is:
- deprecated since January 2014
- completely removed with Git 2.41 (Q2 2023)
Original answer (2012)
Credential Helpers, for Windows, Mac and Unix platforms, have been introduced first in "git-credential-helper" repo, which now has been included in git distro:
This repository contains the set of Git credential helpers (
gitcredentials(7)) that are part ofgit(or meant to be contributed in the future).
$ git clone git://github.com/pah/git-credential-helper.git
$ BACKEND=gnome-keyring # or any other backend
$ cd git-credential-helper/$BACKEND
$ make
$ cp git-credential-$BACKEND /path/to/git/crendential
When built, it would be installed in /path/to/git/credential directory.
To use this backend, you can add it to your (global) Git configuration by setting
(here for Unix):
git config --global credential.helper /path/to/git/credential/gnome-keyring/git-credential-gnome-keyring
Note for Windows:
I suppose you could make a program running on Windows and calling a library like "pypi keyring 0.10".
But that is the back-end, and you don't use it directly from Git.
What you are using is a "credential helper" (which, in turn, will call any credential API it wants on Windows).
GitHub for Windows provides such a helper (as an executable called... github), and can store your credentials for the duration of the Windows session.
Launch a shell from that "GitHub for Windows" windows, and you will see, typing "git config --system -l":
C:\Users\VonC\Documents\GitHub\test [master +2 ~0 -0 !]> git config --system -l
credential.helper=!github --credentials
The credential.helper=!github --credentials part will call the credential helper 'github'.
$ git config [--global] credential.helper $BACKEND
Update October 2018
GNOME has deprecated libgnome-keyring and replaced it with libsecret. Commit https://github.com/git/git/commit/87d1353a6a added a new credential helper /usr/libexec/git-core/git-credential-libsecret.
git config --global credential.helper libsecret
For anyone on Fedora, I edited James Ward's answer slightly:
sudo yum install libgnome-keyring-devel
cd /usr/share/doc/git/contrib/credential/gnome-keyring
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
/usr/libexec/git-core/git-credential-gnome-keyring.git config --global credential.helper gnome-keyringsudo dnf install git-credential-libsecret then git config --global credential.helper libsecretJust add these two lines to your ~/.gitconfig file:
[credential]
helper = gnome-keyring
Next time you are asked for a password by Git, the entered password will be saved to Gnome Keyring (you can see this with seahorse tool), and you won't be asked for the password again afterwards.
This assumes that your Git version is sufficiently new (like 2.1.0) and you are under (削除) Linux (削除ここまで) Fedora, RHEL or CentOS. For older versions or other OSs/distros check out the other answers.
git: 'credential-gnome-keyring' is not a git command.On Fedora you need to install
$ sudo dnf install git-credential-libsecret
and edit your git configuration to use the credential helper.
[credential]
helper = /usr/libexec/git-core/git-credential-libsecret
or
Run
git config --global credential.helper /usr/libexec/git-core/git-credential-libsecret
FYI the libsecret package has recently been split up, see post from @rugk. That's why users need to reinstall this package.
This works as of Feb 2025
Comments
Some distributions do come with this integration as an installation package, without requiring any compilation. Depending on your version of GNOME, you will need to install either gnome-keyring or libsecret versions of the package, something like git-credential-gnome-keyring (OpenSUSE Leap 42.3).
However, this in itself will not enable Git integration with the GNOME Keyring automatically. You must still configure Git to use this method of credential storage:
git config --global credential.helper gnome-keyring # If you installed git-credential-gnome-keyring
git config --global credential.helper libsecret # If you installed git-credential-libsecret
gnome-keyring option does no more work for me, but James Ward's instruction using libsecret still works well. I was, however, confused by the recommendation to use gnome-keyring given here: github.com/timhughes/git-credential-libsecret libsecret (or what find /usr -iname git-credential-libsecret gives) is the right option in Gentoo Linux. Note that dev-vcs/git must be emerged with USE=gnome-keyring.I was trying the answer for Ubuntu on a headless server and I got the following errors when entering my token:
Remote error from secret service: org.freedesktop.DBus.Error.UnknownMethod: No such interface 'org.freedesktop.Secret.Collection' on object at path /org/freedesktop/secrets/collection/login
store failed: No such interface 'org.freedesktop.Secret.Collection' on object at path /org/freedesktop/secrets/collection/login
Here is the solution that worked for me on the headless server (see https://keyring.readthedocs.io/en/latest/#using-keyring-on-headless-linux-systems):
- First I ran the same commands as in the answer to set
git-credential-libsecretas thecredential.helper:
# You may also first install gnome-keyring if not installed
sudo apt install gnome-keyring
sudo apt install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
- Then, whenever I start a session where I will make use of the credentials (e.g. commands like
git push), I run:
dbus-run-session -- sh # Replace 'sh' with whatever shell you use.
gnome-keyring-daemon --unlock
# Enter your token here, then hit Enter, then Ctrl+d
# You might clean the terminal display with Ctrl+l for security reasons
This runs a D-Bus session inside which the I can run for example git push and the likes with automatic authentication.
Arch Linux's git package includes git-credential-libsecret (which replaced git-credential-gnome-keyring), so you can run:
git config --global credential.helper libsecret
As an alternative to entering passwords or personal tokens, you can also try git-credential-oauth.
No more passwords! No more personal access tokens! No more SSH keys!
A Git credential helper that securely authenticates to GitHub, GitLab, BitBucket and other forges using OAuth.
The first time you push, the helper will open a browser window to authenticate. Subsequent pushes within storage lifetime require no interaction.
This is compatible with any storage helper including git-credential-cache or git-credential-libsecret.