Skip to content

Instantly share code, notes, and snippets.

@DreMukare
Created November 18, 2021 15:36
Show Gist options
  • Save DreMukare/dcef7fcaa0d5f6f2419ae4653ab2942c to your computer and use it in GitHub Desktop.
Save DreMukare/dcef7fcaa0d5f6f2419ae4653ab2942c to your computer and use it in GitHub Desktop.
SSH script to connect your linux machine to your github account
#!/usr/bin/env bash
# switch to ssh directory in root
cd ~/.ssh
# generate ssh key named github if it does not exist
if [ ! -f ./github ]; then
echo "please name your file github"
ssh-keygen -t rsa
fi
# direct user to copy public key to their github account
echo "Copy the contents of github.pub to ssh & gpg keys section in your github account settings"
# ignore if already on github
echo "Ignore previous step if key already copied"
# connect key with github
eval "$(ssh-agent -s)"
ssh-add github
ssh -T git@github.com
echo
echo
echo
echo "If it displayed Hi! <your-github-username> you have successfully connected"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment