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
- Inside your GitHub profile, go to settings -> SSH and GPG keys.
- Click New SSH key or Add SSH key.
- 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".
- Paste your key into the "Key" field.
- Click Add SSH key.
That's it! You can now access your remote repositories from your machine using SSH :)