oderfla
oderfla

Reputation: 1797

Cannot store github credentials on aws

I created a brand new github account and then a new repository. Also, I created a github token. Locally on my mac, I run a

git push

and the first time I had to enter username and github-token. After that, it seems terminal never asks for username or password/token.

Then I logged in into my ec2 server and did the same:

git clone myrepo
username: my_username
passowrd: my_token

And I was able to get the code. After that, each time I make a pull in my ec2 server, it always prompts for username/password. So for some reason mac stores credentials but aws doesn't. It seems you need some application? I had a look at this:

https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git

But it seems there is no available version for my ec2? What I understand it uses its own linux distro, called Amazon Linux 2. So the question is: is there a credential manager for aws ec2?

Upvotes: 1

Views: 1518

Answers (1)

Duc Vo
Duc Vo

Reputation: 443

Have you following the instruction?

Link: https://github.com/GitCredentialManager/git-credential-manager/blob/main/docs/credstores.md#gits-built-in-credential-cache

Git's built-in credential cache Available on: Windows, macOS, Linux

export GCM_CREDENTIAL_STORE=cache
# or
git config --global credential.credentialStore cache

This credential store uses Git's built-in ephemeral in-memory credential cache. This helps you reduce the number of times you have to authenticate but doesn't require storing credentials on persistent storage. It's good for scenarios like Azure Cloud Shell or AWS CloudShell, where you don't want to leave credentials on disk but also don't want to re-authenticate on every Git operation.

By default, git credential-cache stores your credentials for 900 seconds. That, and any other options it accepts, may be altered by setting them in the environment variable GCM_CREDENTIAL_CACHE_OPTIONS or the Git config value credential.cacheOptions. (Using the --socket option is untested and unsupported, but there's no reason it shouldn't work.)

export GCM_CREDENTIAL_CACHE_OPTIONS="--timeout 300"
# or
git config --global credential.cacheOptions "--timeout 300"

Upvotes: 4

Related Questions