Created
December 29, 2020 21:00
-
-
Save hachesilva/93110fa86478c61878799515d9238f7d to your computer and use it in GitHub Desktop.
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
# Source: https://gist.github.com/juanique/4092969#gistcomment-3078760 | |
function git_add_ssh_key () { | |
read -p "Enter github email : " email | |
echo "Using email $email" | |
if [ ! -f ~/.ssh/id_rsa ]; then | |
ssh-keygen -t rsa -b 4096 -C "$email" | |
ssh-add ~/.ssh/id_rsa | |
fi | |
pub=`cat ~/.ssh/id_rsa.pub` | |
read -p "Enter github username: " githubuser | |
echo "Using username $githubuser" | |
read -s -p "Enter github password for user $githubuser: " githubpass | |
echo | |
read -p "Enter github OTP: " otp | |
echo "Using otp $otp" | |
echo | |
confirm | |
curl -u "$githubuser:$githubpass" -X POST -d "{\"title\":\"`hostname`\",\"key\":\"$pub\"}" --header "x-github-otp: $otp" https://api.github.com/user/keys | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment