0% found this document useful (0 votes)
8 views2 pages

SSH Auth Github

This guide provides steps for setting up SSH authentication with GitHub for secure, password-free access. It includes checking for existing SSH keys, generating a new key, adding it to the SSH agent, and configuring Git to use SSH. The document also covers troubleshooting tips for common issues during the setup process.

Uploaded by

dhananjayvadane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

SSH Auth Github

This guide provides steps for setting up SSH authentication with GitHub for secure, password-free access. It includes checking for existing SSH keys, generating a new key, adding it to the SSH agent, and configuring Git to use SSH. The document also covers troubleshooting tips for common issues during the setup process.

Uploaded by

dhananjayvadane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Secure GitHub Authentication with SSH

## Introduction
Using SSH authentication with GitHub allows secure, password-free access when pushing code.
This guide walks you through generating, adding, and using an SSH key for GitHub authentication.

## Step 1: Check for Existing SSH Keys


Before generating a new key, check if you already have one:
$ ls -al ~/.ssh
If you see id_ed25519.pub or id_rsa.pub, an SSH key already exists.
You can either use it or generate a new one.

## Step 2: Generate a New SSH Key


To generate a new SSH key, run:
$ ssh-keygen -t ed25519 -C "[email protected]"
- -t ed25519: Uses a more secure key algorithm.
- -C "[email protected]": Adds an optional comment (your email) to identify the key.

When prompted, press Enter to save it in the default location (~/.ssh/id_ed25519).


Set a passphrase (optional, but recommended for security).

## Step 3: Add the SSH Key to the SSH Agent


Start the SSH agent:
$ eval "$(ssh-agent -s)"
Add your SSH private key:
$ ssh-add ~/.ssh/id_ed25519

## Step 4: Add Your SSH Key to GitHub


Copy your public SSH key:
$ cat ~/.ssh/id_ed25519.pub

1. Go to GitHub, Click on your profile, then Settings.


2. Navigate to SSH and GPG keys, then click New SSH Key.
3. Paste the copied key into the Key field.
4. Click Add SSH Key.

## Step 5: Test Your SSH Connection


To confirm everything is set up correctly, run:
$ ssh -T [email protected]

Expected output:
Hi YOUR_GITHUB_USERNAME! You've successfully authenticated, but GitHub does not provide
shell access.

## Step 6: Configure Git to Use SSH


If your repository is using HTTPS, switch it to SSH:
$ git remote remove origin
$ git remote add origin [email protected]:YourUsername/YourRepo.git

Now, push your code using SSH:


$ git push -u origin main

## Conclusion
You have successfully set up SSH authentication for GitHub. Now you can push code without
entering a password each time.

### Troubleshooting
- If authentication fails, ensure your SSH key is added to GitHub.
- If permission is denied, check your SSH agent with:
$ ssh-add -l
- If your key is not listed, re-add it:
$ ssh-add ~/.ssh/id_ed25519

For more details, refer to GitHub's official SSH guide:


https://docs.github.com/en/authentication/connecting-to-github-with-ssh

You might also like