Skip to content

Commit

Permalink
Fix creating ssh-key if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
lipusik committed Nov 9, 2022
1 parent 5b55a54 commit c3c101e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions git_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@ git config --global user.email "$EMAIL"
echo "Configuring global aliases..."
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.last 'log -1 HEAD'
git config --global alias.sub "submodule update --remote --merge"
git config --global core.editor "vim"
git config --global credential.helper 'cache --timeout=36000'

read -r -p "Do you want to add ssh credentials for git? [y/n] " RESP
RESP=${RESP,,} # tolower (only works with /bin/bash)
if [[ $RESP =~ ^(yes|y)$ ]]

CHECK_KEY_ED_EXISTS="$HOME/.ssh/id_ed25519.pub"
if [[ $RESP =~ ^(yes|y)$ ]] && ! test -f "$CHECK_KEY_ED_EXISTS"
then
echo "Configuring git ssh access..."
ssh-keygen -t ed25519 -C "$EMAIL"
echo "This is your public key. To activate it in github, got to settings, SHH and GPG keys, New SSH key, and enter the following key:"
cat ~/.ssh/id_ed25519.pub
echo ""
echo "To work with the ssh key, you have to clone all your repos with ssh instead of https. For example, for this repo you will have to use the url: [email protected]:miguelgfierro/scripts.git"
echo -e "\nTo work with the ssh key, you have to clone all your repos with ssh instead of https. For example, for this repo you will have to use the url: [email protected]:miguelgfierro/scripts.git"
else
echo "You have already ssh-key. To activate it in github, got to settings, SHH and GPG keys, New SSH key, and enter the following key:"
cat ~/.ssh/id_ed25519.pub
fi

if [ "$(uname)" == "Darwin" ]; then # Mac OS X platform
Expand Down

0 comments on commit c3c101e

Please sign in to comment.