Currently, whenever I git pull
or git push
to a http(s) repository, I get the following:
$ git pull
Username for 'https://gitrepos.reposdomain.com': [email protected]
Password for 'https://[email protected]@gitrepos.reposdomain.com':
This is ok for infrequent use, but starts to become really annoying very quickly. Unfortunately, switching to ssh is not an option in this case.
I've read that earlier versions of git
provided a credential "store" and "cache", but that this wasn't advised because it stored the password in plaintext.
BUT
Newer versions of git
apparently store git credentials in the gnome-keyring
, but it has to be set up correctly.
I've tried following other (non-Ubuntu) answers on SO to get this to work (namely this one), but I'm still presented with the username and password prompt.
What is the correct and safest way to store git
credentials for http(s) repos and how does one make them work on Ubuntu?
gnome-credential-helper
is now deprecated.Instead, use libsecret. If it's not already pre-installed on your machine, use the following procedure:
Make sure
libsecret
and its development libraries are installed:Then build the credential helper from the sources shipped with libsecret's development libraries:
Finally, register the freshly compiled binary as a Git credential helper:
More details on https://stackoverflow.com/a/40312117/2017781
You need to setup the git
credential helper
with Gnome Keyring:Install and compile the Gnome Keyring devel:
And setup the credential:
This simple approach appears to be sufficient on my Ubuntu 18.04.1 with git 2.17.1:
You can specify a one hour (=3600 seconds) timeout like this:
Further reading in the fine manual.