How to Authenticate With GitHub From The Terminal?

Recently, I wanted to authenticate with GitHub from the terminal on a newly installed machine. The process to authenticate with GitHub using SSH requires two steps.

Step 1: Generate a private key file on your local machine

Inside your terminal, type the following command:

ssh-keygen -t ed25519 -C "your_email@example.com"

This creates a new SSH key, using the provided email as a label.

When you're prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location.

> Enter a file in which to save the key (/home/YourUsername/.ssh/ALGORITHM):[Press enter]

inside the path C:\Users\YourUsername\.ssh, you can find the generated public and private keys.

The public key will have the extension .pub, which we will use in the next step.

Step 2: Add your public key to your GitHub profile settings

  1. Inside your GitHub profile, go to settings -> SSH and GPG keys.
  2. Click New SSH key or Add SSH key.
  3. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".
  4. Paste your key into the "Key" field.
  5. Click Add SSH key.

That's it! You can now access your remote repositories from your machine using SSH :)

About The Author
Author Avatar
Mohamed AbdelGawad

IT Automation Specialist

Hi and welcome to my blog where I like to record and document the technical issues I tackle and the solutions I apply. Hopefully, it will make someone's life easier.

I'd love to hear your thoughts...

Get in Touch.

Whether you have a question or just want to say hi, I’ll try my best to get back to you as soon as possible.