by

Using Git with GNOME Keyring

A default Git installation ships with several credential helpers, so we need to configure Git to use one of these helpers. But this story wouldn’t be about Linux if we could get away without running a make command. The directory /usr/share/doc/git/contrib/credential contains several helpers, including libsecret and gnome-keyring. According to this StackOverflow post we should use libsecret, so lets configure Git to use it:

sudo apt install make gcc 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

The next time we call git push the provided credentials (GitHub username + personal access token) are stored in the keyring. Tools such as seahorse (GUI) or secret-tool (CLI) can be used to search or manage stored keys.

To cleanup all credential.helpers:

git config --global --unset-all credential.helper

Write a Comment

Comment