I'm new to using Gitlab. My workplace has recently moved from on-prem Git to a cloud-based Gitlab host. I used ssh authentication in the past with our on-prem so never had to deal with credentials hanging around (I'm using Linux) in .git/config or ~/.gitconfig.
If I let git manage my credentials/tokens, with whatever defaults it uses, those creds/tokens end up stored in plaintext in my home directory under ~/.git-credentials or in the .git/config file, which is problematic for various reasons.
I poked around and found Git Credential Manager Core but after getting it installed, as shown in the README, I'm not exactly sure it's working correctly, or I'm misunderstanding how to use it. I ran these commands to get it setup:
dpkg -i gcm-linux_amd64.2.0.785.debgit-credential-manager-core configuregit config --global credential.credentialStore gpgpass init <gpg-id>I tried cloning a cloud-based repo using a personal access token, but when I clone it, gpg prompts me for my passphrase, but the token ends up in the .git/config file anyway.
$ git clone https://user-test-token:[email protected]/my.username/my-repo.git
$ cat .git/config
...
[remote "origin"]
url = https://user-test-token:[email protected]/my.username/my-repo.git
...
What am I doing wrong?
In your git clone command, you inserted a personal access token into the remote URL. This is insecure and prevents Git from calling any configured credential helpers. Instead, you should clone with the unadorned remote URL.
Next, Git Credential Manager only supports gitlab.com out the box (see GitLab issue #374172). To use with another GitLab instance such as gitlab.example.com, follow the instructions at https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/gitlab.md .
For what it's worth, you might find it easier to use git-credential-oauth, included in many Linux distributions including Fedora, Debian and Ubuntu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With