Complete and safe guide to create an SSH key, add it to GitHub

Here's a complete and safe guide to create an SSH key, add it to GitHub, and start using it to push/pull code securely:


✅ STEP 1: Generate a New SSH Key

On your local machine, run:

ssh-keygen -t ed25519 -C "your_email@example.com"

Replace "your_email@example.com" with your GitHub email.

You’ll see:

Enter file in which to save the key (/home/your-user/.ssh/id_ed25519):

Just press Enter to accept the default path.

Then:

Enter passphrase (optional): 
  • You can press Enter for no passphrase
  • Or enter one for extra security

✅ This creates:

  • Private key: ~/.ssh/id_ed25519
  • Public key: ~/.ssh/id_ed25519.pub

✅ STEP 2: Add SSH Key to SSH Agent

Run:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

This loads your SSH key into the agent so Git can use it.


✅ STEP 3: Add SSH Key to GitHub

  1. Show your public key:

    cat ~/.ssh/id_ed25519.pub
    
  2. Copy the entire output (starts with ssh-ed25519…)

  3. Go to: https://github.com/settings/keys

  4. Click "New SSH key"

    • Title: Any label (e.g., "My Laptop")
    • Key: Paste the public key you copied
  5. Click "Add SSH key"


✅ STEP 4: Test the SSH Connection

ssh -T git@github.com

You should see:

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

✅ STEP 5: Use SSH for Your Repos

When cloning a repo, use this:

git clone git@github.com:your-username/your-repo.git

Or change your remote URL in an existing repo:

git remote set-url origin git@github.com:your-username/your-repo.git

🛠 Bonus Tip: Configure Git Identity (if not done)

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

PARTNER WITH US TO CREATE A COMPELLING NARRATIVE
FOR YOUR BRAND!

Let's bring your ideas to life, start collaborating with our creative agency and turn your vision into reality.