Last active
April 29, 2023 02:46
-
-
Save jigangkim/fd32556aae2e81546a8b0cce28558d11 to your computer and use it in GitHub Desktop.
Auto setup for GIT_ASKPASS with support for encrypted tokens (https://jigang.kim/blog/replace-github-token-with-password/)
This file contains 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
alias gitoken='source ~/autosetup/github-setup.sh' |
This file contains 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
#!/usr/bin/env bash | |
echo -n "Encrypted token: " | |
read secret | |
echo -n "Password: " | |
read -s password | |
echo | |
echo -n "Token: " | |
token=`echo $secret | openssl aes-256-cbc -pbkdf2 -d -a -pass pass:$password` | |
echo $token | |
echo 'echo $GIT_TOKEN' > $HOME/.git-askpass | |
chmod +x $HOME/.git-askpass | |
export GIT_TOKEN=$token | |
export GIT_ASKPASS=$HOME/.git-askpass |
This file contains 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
#!/usr/bin/env bash | |
echo -n "Encrypted token: " | |
read secret | |
echo -n "Password: " | |
read -s password | |
echo | |
echo -n "Token: " | |
echo $secret | openssl aes-256-cbc -pbkdf2 -d -a -pass pass:$password |
This file contains 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
#!/usr/bin/env bash | |
echo -n "Token: " | |
read -s token | |
echo | |
echo -n "Enter password: " | |
read -s password1 | |
echo | |
echo -n "Retype password: " | |
read -s password2 | |
echo | |
if [[ "$password1" == "$password2" ]]; then | |
echo -n "Encrypted token: " | |
echo $token | openssl aes-256-cbc -pbkdf2 -a -salt -pass pass:$password1 | |
else | |
echo "Password does not match!" | |
fi |
This file contains 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
#!/usr/bin/env bash | |
secret=<your encryted github token goes here> | |
echo -n "Password: " | |
read -s password | |
echo | |
token=`echo $secret | openssl aes-256-cbc -pbkdf2 -d -a -pass pass:$password` | |
echo 'echo $GIT_TOKEN' > $HOME/.git-askpass | |
chmod +x $HOME/.git-askpass | |
export GIT_TOKEN=$token | |
export GIT_ASKPASS=$HOME/.git-askpass |
This file contains 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
source auto-setup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment