Last active
December 1, 2020 20:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] .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 [email protected] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment