This article explains how to clone your git repo with SSH on Linux.

Authentication

Don’t forget that you will still need to authenticate with git by running:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

1. generate an ssh key

Paste this command in your terminal

ssh-keygen -t ed25519 -C "your_email@example.com"
  • You’ll be prompted to choose a file to save the key (default is ~/.ssh/id_ed25519)
  • Press Enter to accept the default path.
  • You can also set a passphrase for extra security. (or press enter for no passphrase) And you’ll also get a funy artwork :3

2. Add the SSH Key to the SSH Agent

# Start ssh-agent in the background
eval "$(ssh-agent -s)"

# The actual command
ssh-add ~/.ssh/id_ed25519

3. copy the pub key

cat ~/.ssh/id_ed25519.pub

4. copy SSH Key

open ~/.ssh/id_ed25519.pub in a text editor and copy it’s contents

5. Add the SSH Key to Your Git Host (GitHub example)

  1. Go to GitHub → Settings → SSH and GPG keys
  2. Click New SSH key
  3. Paste your key and give it a name
  4. Save

5. Use SSH to Clone Repositories

  1. On the git repo page, under the blue or green clone / code button, it is default chosen HTTPS, select SSH instead
  2. Clone the link
  3. in your terminal, type git clone <paste the link> and press enter