top of page

Github - Add SSH Key

Setting up GitHub involves creating an account and configuring Git on your local machine to interact with GitHub. Here’s a step-by-step guide to get started:


✅ 1. Create a GitHub Account


GitHub is a platform for hosting and sharing code using Git. To use it:

  1. Visit https://github.com

  2. Click Sign up

  3. Fill in your username, email, and password

  4. Verify your email and follow the setup prompts


📘 GitHub is like Dropbox, but specifically for code — and with tools for version control and collaboration.


✅ 2. Install Git on Your Computer


Git is the tool you’ll use to track and manage changes in your code.


🖥 On macOS:

Install Git using Homebrew:

brew install git

🪟 On Windows:

  1. Download Git from: https://git-scm.com/download/win

  2. Run the installer (keep the default settings unless you know what you're doing)

  3. This will install Git Bash, a terminal where you’ll run Git commands


✅ 3. Configure Git with Your Info


This links your Git commits to your identity.

Open Terminal (macOS) or Git Bash (Windows) and run:

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

Check your setup:

git config --global --list

🪪 This information shows up in your commit history, so others know who made each change.


✅ 4. Set Up SSH Key


🤔 What is an SSH Key?

An SSH key is a secure way to connect your computer to GitHub without typing your username and password every time.

It uses a public/private key pair:

  • The private key stays on your computer

  • The public key gets uploaded to GitHub

  • Together, they verify your identity when pushing code


🛠 Generate the SSH Key:

ssh-keygen -t ed25519 -C "your-email@example.com"

Just hit Enter to accept the default file location, and optionally add a passphrase.


🔑 Start the SSH Agent and Add Your Key

On macOS:

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

On Windows (in Git Bash):

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

📋 Copy Your Public Key:

cat ~/.ssh/id_ed25519.pub

Copy the output — it looks like a long string starting with ssh-ed25519.


🔗 Add Key to GitHub:

  1. Go to GitHub.com

  2. Click your profile picture → Settings

  3. Navigate to SSH and GPG keys

  4. Click New SSH key

  5. Paste the key and save


✅ Now GitHub will recognize your computer and won’t ask for your password every time.

✅ 5. Clone a Repository (Download a GitHub Project)


To get a copy of a GitHub repository:

git clone git@github.com:username/repo-name.git # SSH version

Or if you didn’t set up SSH:


✅ 6. Create and Push to Your Own Repository


  1. On GitHub, click +New repository

  2. Name your repo and click Create repository

Now, in Terminal or Git Bash:

git init # Start a new Git project 
git remote add origin git@github.com:yourusername/your-repo.git

Then:

git add . # Add all files
git commit -m "Initial commit" # Save a snapshot 
git push -u origin main # Upload to GitHub

📤 Your code is now backed up on GitHub and others can collaborate.


✅ Optional Tools

Tool

What it does

macOS

Windows

VS Code

Code editor with Git integration

GitHub Desktop

GUI for Git/GitHub

Git Bash

Terminal for Git commands

N/A

Homebrew

Package manager for easy installs

✅ Final Test


To confirm your setup, try this:

git --version # Should show Git version 
ssh -T git@github.com # Should say "Hi yourusername!"

radek@Mac VSCodeProjects % ssh -T git@github.com
The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
ED25519 key fingerprint is SHA256:+Dxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Hi radsto6631! You've successfully authenticated, but GitHub does not provide shell access.


 
 
bottom of page