the wiki of cscosine
This guide explains how to create an SSH key and add it to GitHub so you can access repositories without using a password.
Open a terminal and run:
ls -al ~/.ssh
Look for files like:
id_ed25519
id_ed25519.pub
If they exist, you can reuse them. Otherwise create a new key.
Run:
ssh-keygen -t ed25519 -C "your_email@example.com"
Explanation:
-t ed25519 → modern secure key type-C → comment (usually your GitHub email)You’ll see prompts like:
Enter file in which to save the key:
/home/you/.ssh/id_ed25519
Press Enter to accept the default.
Then optionally enter a passphrase for extra security.
This creates:
~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub
This step is recommended but not always required.
Start the SSH agent:
eval "$(ssh-agent -s)"
Example output:
Agent pid 1234
ssh-add ~/.ssh/id_ed25519
This allows the key to be reused without entering the passphrase repeatedly.
Display the public key:
cat ~/.ssh/id_ed25519.pub
Copy the entire output.
Example:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your_email@example.com
Title
My Laptop
Key
Paste your copied key.
ssh -T git@github.com
Expected output:
Hi username! You've successfully authenticated...
Instead of the HTTPS URL:
https://github.com/user/repo.git
Use the SSH URL:
git@github.com:user/repo.git
Example:
git clone git@github.com:user/repo.git
The steps are similar but use PowerShell or Git Bash.
Open PowerShell and run:
ls $env:USERPROFILE\.ssh
Look for:
id_ed25519
id_ed25519.pub
If they exist, you can reuse them.
Run:
ssh-keygen -t ed25519 -C "your_email@example.com"
When prompted for the file location:
C:\Users\YourUser\.ssh\id_ed25519
Press Enter to accept the default.
Optionally set a passphrase.
Enable and start the Windows SSH agent:
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
Display the key:
type $env:USERPROFILE\.ssh\id_ed25519.pub
Copy the entire output.
Example:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your_email@example.com
Run:
ssh -T git@github.com
Expected output:
Hi username! You've successfully authenticated...
Check if the SSH agent is running:
ssh-add -l
Possible outputs:
The agent has no identities.
or
Could not open a connection to your authentication agent.
If needed, start the agent and add the key again.