Blog

EN
Set up your SSH keys on GitHub

Set up your SSH keys on GitHub

5 min read

Stop typing your username and password every time you do a git push, or if you simply want to improve security.

What is an SSH key and what is it used for?

SSH (Secure Shell) is a protocol that allows two computers to connect securely over an insecure network. In the context of GitHub, it works like a “digital key.”

Imagine you have a special lock on your GitHub account. Instead of using a password that can be stolen, you use a key pair:

  1. Public Key: You give this to GitHub. It’s public, and it doesn’t matter if someone else sees it.
  2. Private Key: This stays stored exclusively on your computer. No one else should have it.

It is used for:

  • Security: It’s much harder to compromise than a traditional password.
  • Convenience: Once configured, GitHub will recognize your computer automatically.

Add your SSH key to GitHub

1. Generate a new SSH key

First, create the key pair on your computer. Open your terminal (or Git Bash if you’re on Windows) and run the following command.

We recommend the ed25519 algorithm because it’s more secure and faster than the older RSA.

ssh-keygen -t ed25519 -C "[email protected]"

The system will ask where to save the key. Just press Enter to accept the default location. Then it will ask for a passphrase; you can leave it empty for convenience or set one for extra security.

2. Enable the SSH agent

Now we need your system to remember this key so it can use it.

  1. Start the SSH agent in the background:
eval "$(ssh-agent -s)"

You should see a message like Agent pid 12345.

  1. Add your private key to the agent:
ssh-add ~/.ssh/id_ed25519

3. Copy the public key

We need to copy the contents of your public key (the file that ends with .pub) to paste it into GitHub.

  • Mac: pbcopy < ~/.ssh/id_ed25519.pub
  • In Windows (PowerShell): cat ~/.ssh/id_ed25519.pub | clip
  • In Linux: xclip -selection clipboard < ~/.ssh/id_ed25519.pub (or simply use cat ~/.ssh/id_ed25519.pub and copy it manually from the terminal).

4. Add the key to GitHub

  1. Go to your GitHub account and click your profile picture (top-right corner) > Settings.

Settings Github

  1. In the left sidebar, find and click SSH and GPG keys.
  2. Click the green button that says New SSH key.

Settings SSH Keys Github

  1. Title: Give it a name to identify your PC (e.g., “My Personal Laptop”).
  2. Key: Paste the key you copied in the previous step.
  3. Click Add SSH key.

You can now clone, push, and pull changes from your repositories without needing passwords.

Share this article on

Avatar byandrev

Andres Parra

Software Engineer

I'm Andres Parra, Software Engineer passionate about developing scalable and innovative technological solutions. I specialize in building modern web applications, mastering a versatile stack that includes JavaScript, TypeScript, Python, and Java, along with frameworks like React, Next.js, and Spring Boot. I'm also interested in the latest technologies and tools for development.