An open API service indexing awesome lists of open source software.

https://github.com/chmodshubham/set-ssh-authentication

Setting Up SSH Authentication for GitHub
https://github.com/chmodshubham/set-ssh-authentication

authentication github ssh

Last synced: 9 months ago
JSON representation

Setting Up SSH Authentication for GitHub

Awesome Lists containing this project

README

          

# Setting Up SSH Authentication for GitHub

## When is it Needed?

SSH keys are required for secure, password-less authentication to GitHub. This is necessary when you want to perform Git operations (like clone, push, pull) over SSH. It's particularly useful for:

- Automated scripts that interact with GitHub repositories.
- Contributing to repositories without entering your username and password each time.
- Enhanced security for repository access.

## Setting Up Your Environment for GitHub

Before setting up SSH keys for secure GitHub access, it's important to configure your Git username and email. This information is used in your commits.

### Configure Git Username and Email

1. **Set Your Git Username**

```bash
git config --global user.name "Your Name"
```

- Replace `Your Name` with your desired username.

2. **Set Your Git Email**

```bash
git config --global user.email "your_email@example.com"
```

- Replace `your_email@example.com` with your email address.

## Steps to Add an SSH Key to Your GitHub Account

### 1. Generate an SSH Key (if you don't have one)

First, check if you already have an SSH key generated by running `ls -al ~/.ssh` in your terminal. Look for files named `id_rsa` and `id_rsa.pub`. If these files do not exist, generate a new SSH key with:

```bash
ssh-keygen
```

### 2. Copy the SSH Public Key

Open the public key file in a text editor and copy its contents. You can also use the command:

```bash
cat ~/.ssh/id_rsa.pub
```

Then, manually copy the output.

### 3. Add the Key to GitHub

- Log in to your [GitHub account](https://github.com).
- Click your profile picture in the top right corner, and select **Settings**.
- In the user settings sidebar, click **SSH and GPG keys**.
- Click the **New SSH key** button.
- In the **Title** field, enter a descriptive name for your key.
- In the **Key** field, paste your public SSH key.
- Click **Add SSH key** to save the new key.

### 4. Test Your SSH Connection

To ensure that your setup is working correctly, you can test your SSH connection to GitHub by running:

```bash
ssh -T git@github.com
```

You should receive a success message confirming your authentication.