Skip to content

Instantly share code, notes, and snippets.

@gnthibault
Last active December 1, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnthibault/970d0d30644a5162cd4e9068f49151ef to your computer and use it in GitHub Desktop.
Save gnthibault/970d0d30644a5162cd4e9068f49151ef to your computer and use it in GitHub Desktop.
Safe access for multiple user on the same account on a linux machine
First task is to create your own token (generate new token):
https://github.com/settings/tokens
you can test it with
curl -u <token>:x-oauth-basic https://api.github.com/user
Then write it down to a specific file in home/user/subuser/.netrc , where you just created your directory
content of the file:
machine github.com
login <githubUserName>
password <token>
protocol https
#Then encrypt it
gpg --gen-key
gpg --encrypt --armor --recipient user.name@yourmail.com .netrc
#then give it the right permission, and the right file extension
chmod 700 ./.netrc.asc
mv ./.netrc.asc ./.netrc.gpg
#Now, try to clone your repo:
git clone https://github.com/githubuser/repo.git
give you token as password
#Inform it of your local configuration, so that next time you don't need to rewrite it:
git config --local credential.helper 'netrc -f /home/user/subuser/.netrc.gpg -d -v'
you might need to do download the perl script (see this gist) and make is executable and inside the current $PATH:
chmod +x ~/bin/credential-git-credential-netrc
Test with
gpg --decrypt /home/user/subuser/.netrc.gpg
cross check git config with
git config -e
git config --local user.name githubUserName
git config --local user.email user.name@yourmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment