Created
November 18, 2021 15:36
-
-
Save DreMukare/dcef7fcaa0d5f6f2419ae4653ab2942c to your computer and use it in GitHub Desktop.
SSH script to connect your linux machine to your github account
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 | |
# 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