Git Credential Manager (GCM) Setup on Linux
December 26, 2022
If you’re on Linux, you may be tired of inputting your
credentials every time you are pushing to a git repository in
GitHub. If you want to save your credentials so they
are automatically used, then you can use
git-credential-manager
. Here’s how you can set it up on
Debian-based distributions.
Official Repository of GCM
The official repository of the git-credential-manager
is
found here: https://github.com/GitCredentialManager/git-credential-manager.
Feel free to do some overview reading in what it does.
Download git-credential-manager
Download the .deb
file: https://github.com/GitCredentialManager/git-credential-manager/blob/release/docs/install.md#debian-package
Installation
Follow these instructions, or the ones in the official repository.
- Navigate to where you downloaded GCM.
- Run the following command:
sudo dpkg -i <path-to-package>
git-credential-manager configure
GPG
Before going further, we will need to figure out a way to store the token which will be used.
- If you don’t have
gnupg
installed already, you can install it:
sudo apt install gnupg
- Next, you can install
kgpg
which is a GUI tool to add RSA key pairs. Usekgpg
to generate a 4096 bit key. - Then you can make note of the ID and use it to configure
git-credential-manager
.
Install pass
Use pass
to manage the password. It will need the GPG
key ID to be used to encrypt the keys.
- Install
pass
:
sudo apt install pass
- Configure it:
pass init <gpg-key-id>
Where gpg-key-id
is the key ID of the GPG RSA key pair
you have generated.
Configuring
Now it is time to configure git-credential-manager
to
use gpg
.
git config --global credential.credentialStore gpg
Testing
Navigate to any repository, make a commit, and push. A new popup should appear and you can use the Token option by clicking on the Token tab and entering in your PAT.