Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Guide · OtherFree

Connecting to GitHub with SSH (GitHub Docs)

GitHub's official guide to SSH keys: checking for existing keys, generating a new key, adding it to the SSH agent and to your account, and testing the connection, with separate instructions for macOS, Windows and Linux. The reliable way to set up key-based access to GitHub.

Format

Guide

Topic

Other

Provider

GitHub

Time needed

About 30 minutes

Level

Beginner

Access

Free

What it is

This section of GitHub Docs explains how to use SSH to authenticate with GitHub. It is split into short steps: about SSH, checking for existing SSH keys, generating a new key and adding it to the ssh-agent, adding the key to your GitHub account, testing the connection, working with passphrases and troubleshooting. Each page has tabs for macOS, Windows and Linux, which matters because the agent and key storage differ slightly by operating system.

Why it matters

GitHub does not accept your account password for Git operations. You either use SSH keys or a personal access token over HTTPS. SSH keys are the common choice for developers who push from their own machines: set up once per machine, protected by a passphrase, and never sent over the network. The same skills, generating keys, understanding public versus private keys, and using an agent, carry straight over to logging into servers.

What you will do

  1. Check ~/.ssh for existing keys.
  2. Generate a new key, with GitHub currently recommending the Ed25519 type: ssh-keygen -t ed25519 -C "your_email@example.com".
  3. Add the key to the ssh-agent so you do not type the passphrase every time.
  4. Copy the public key (the .pub file) into your GitHub account settings.
  5. Test with ssh -T git@github.com.

Tips from experience

  • On Windows with WSL, follow the Linux instructions inside Ubuntu, since that is where you run Git.
  • Use a passphrase. The agent means you rarely type it.
  • Never share or upload the private key. A new machine gets a new key.
  • If a clone URL starts with https://, switch the remote to the git@github.com: form to use SSH.

Is it worth it?

Yes. Blog posts on SSH keys often use outdated key types or skip the agent. The official docs are current, short and cover each operating system.

Common questions

SSH or HTTPS with a token? Either works. SSH is convenient on your own machines; tokens are common in scripts and CI.

Can I use one key for several GitHub accounts? A key can only be attached to one account; use separate keys and an SSH config file for several accounts.

Is it free? Yes.

gitbeginner friendlydevops

Ready to start?

Opens on GitHub in a new tab.

Open resource
Link broken or out of date?

Report a problem

With "Connecting to GitHub with SSH (GitHub Docs)". Only Tauseef reads this.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.