Skip to content

Instantly share code, notes, and snippets.

@shabayekdes
Last active December 2, 2021 11:44
Show Gist options
  • Save shabayekdes/f70e30b4aca60be49cdbdcbd804b8e3e to your computer and use it in GitHub Desktop.
Save shabayekdes/f70e30b4aca60be49cdbdcbd804b8e3e to your computer and use it in GitHub Desktop.
Configure Git SSH Keys

Step 1: Create SSH directory in home

mkdir $HOME/.ssh

Step 2: Generate a new set of keys

ssh-keygen -t rsa -b 4096 -C "esmail.shabayek@gmail.com"
  • You will then be prompted to "Enter a file in which to save the key." You can specify a file location or press “Enter” to accept the default file location.
  • The next prompt will ask for a secure passphrase. A passphrase will add an additional layer of security to the SSH and will be required anytime the SSH key is used.

Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]

Step 3: Add your SSH key to ssh-agent

eval "$(ssh-agent -s)"

Step 4: Add your private key to ssh-agent

ssh-add ~/.ssh/id_rsa

Step 5: Copy your public SSH key

cat ~/.ssh/id_rsa.pub

Finally, test your authentication

ssh -T git@github.com
OR
ssh -T git@gitlab.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment