Skip to content

Instantly share code, notes, and snippets.

@sodogan
Last active December 13, 2021 16:54
Show Gist options
  • Save sodogan/0b935bd5c29f7c1c4737634d7c70b34f to your computer and use it in GitHub Desktop.
Save sodogan/0b935bd5c29f7c1c4737634d7c70b34f to your computer and use it in GitHub Desktop.
Generating SSH Key for GIT

How to generate the SSH Key

  • Make sure that you set the username and email address via git config
  • git config --global user.email "solendogan.sap@gmail.com"

For all the operations we will use git bash,its like a linux environment! ##STEPS

  • First generate the Public and Private Keys, go to Git bash

    ssh-keygen -t rsa -b 4096 -C "solendogan.sap@gmail.com"

    Follow and save all the defaults, dont choose another path to save!

    Make sure you choose a passphrase, you can leave it blank but not recommended! if success it will generate a .rsa(private key) and id_rsa.pub(public key) under .ssh folder

  • Add the key to the SSH Key agent

    eval "$(ssh-agent -s)"

    ssh-add ~/.ssh/id_rsa

    Now we have added the SSH Key to our system next step is to add the public key to your Github Account

  • Copy your public Key Git bash you can use clip cat ~/.ssh/id_rsa.pub | clip or

    clip < ~/.ssh/id_rsa.pub

  • Go and add the public key that you copied to your github account!

    Go to Settings under SSH and GPG Keys Create a new SSH Key naming it like Work_laptop Then paste the RSA Key and save.

You are all set and can use SSH key to clone or push to a repo without using uername and password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment