Table of Contents

Using SSH Keys with GitHub

Why Use SSH Keys?

Generating an SSH Key

1. Open your terminal. 2. Generate a new SSH key pair:

ssh-keygen -t ed25519 -C "[email protected]"

Replace `[email protected]` with your actual email address. You'll be prompted to enter a file location (default is `~/.ssh/id_ed25519`) and a passphrase. It's recommended to use a passphrase for added security.

3. Locate the public key:

 The public key is located in `~/.ssh/id_ed25519.pub`.

Adding the Public Key to GitHub

  1. Log in to GitHub.
  2. Go to your account settings.
  3. Navigate to the “SSH and GPG keys” section.
  4. Click “New SSH key.”
  5. Give the key a title (e.g., “Your computer”) and paste the contents of your public key into the key text area.
  6. Click “Add SSH key.”

Testing the SSH Connection

  1. Open your terminal.
  2. Run the following command:
   ssh -T [email protected]

If successful, you should see a welcome message from GitHub.

Using SSH with Git

To clone a repository using SSH:

  git clone [email protected]:username/repository_name.git

Replace `username` and `repository_name` with your actual GitHub username and repository name.

Additional Tips

By following these steps, you'll have a secure and efficient way to interact with GitHub.