Configure SSH with GitHub (4096bit Key)
Most of the times, we tend to search this up when a new laptop is being given to you from your workplace. After facing the requirement for several times and have to go through several documentations, thought of drafting this in one sheet for the reference of anyone who needs it to resolve in one-go.
Step 1: Get the GitBash installed in your PC/Laptop
Step 2: Open the command line/terminal
Step 3: Set your username
git config --global user.name “FIRST_NAME LAST_NAME”
Step 4 : Set your email address
git config --global user.email “email@example.com”
Step 5: Check for the updated username and email-address.
git config --list
Step 6: Open GitBash
Step 7: Check if there's an SSH key which has been generated (to take a backup of it)
$ ls -la ~/.ssh/id_rsa*
Step 8: Take a backup of the existing SSH key pair (id_rsa/id_rsa.pub) before regenerating a new key-pair
# Make a copy of the old SSH private key
$ cp ~/.ssh/id_rsa ~/.ssh/id_rsa.old # Make a copy of the old SSH public key
$ cp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa.pub.old
Step 9: Create/Generate a new 4096-bit key pair (private key and public key)
$ ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
Step 10: Enter a file in which you want to save your keys.
(You can press enter and the default ~/.ssh/id_rsa will be used.)
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter-key]
Step 11: Enter a passphrase or your can keep it empty
(but it is not recommended to keep it empty)
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Note: Just press enter-key without typing any key, if you need to keep the passphrase empty.
Step 12: Two new SSH key pair will be generated for the .ssh folder. (C:/Users/you/.ssh/id_rsa)
Step 13: Open the id_rsa.pub file from NPP ofr VSCode and copy the content of it.
Step 14: Navigate to the GitHub account > Settings > SSH and GPG Keys
Step 15: Click on ‘New SSH Key’
Step 16: Add a custom name for title (Tip : Better to add the clue/hint to your passphrase in your title, because this passphrase is easy to forget as not being used frequently)
Step 17: Paste the copied content on the Key section
Step 18: Click on ‘Add SSH Key’