Skip to content
For Devs

How to Link Your SSH Key to GitHub: A Practical, Straightforward Guide for Developers

By Bruno Hoinacki

If you're just starting out in programming, or you're more advanced and diving into the world of version control, at some point you'll run into the concept of SSH keys. Especially when working with platforms like GitHub.

SSH authentication is a secure way to connect to repositories, letting you clone, send (push) and retrieve (pull) code without having to type your username and password over and over. It is also the method recommended by GitHub itself for more professional development environments.

In this article, we'll show you how to link your SSH key to GitHub in a clear, quick and practical way.

What is an SSH key and why use it on GitHub?

SSH (Secure Shell) is a protocol that ensures secure communication between two computers. When you generate a key pair (public and private), you're creating a kind of digital identity. The private key stays with you (on your computer), while the public key is added to GitHub.

This process enables automatic, encrypted and secure authentication without exposing passwords or tokens in every Git operation.

How to generate and link your SSH key to GitHub

1. Check whether you already have an SSH key

Open the terminal and type:

ls -al ~/.ssh

If you see files such as id_rsa.pub and id_rsa, you already have a key pair. If not, move on to the next step.

2. Generate a new SSH key

Use the command below (replace the email with the one for your GitHub account):

ssh-keygen -t ed25519 -C "seu-email@exemplo.com"

If your system doesn't support ed25519, use rsa:

ssh-keygen -t rsa -b 4096 -C "seu-email@exemplo.com"

Press Enter to accept the default file location (~/.ssh/id_ed25519) and, if you want, set a passphrase to protect your key (keep in mind that a passphrase is not required).

3. Add your private key to the SSH agent

Make sure the agent is running:

eval "$(ssh-agent -s)"

Add your key to the agent:

ssh-add ~/.ssh/id_ed25519

4. Copy the public key

Now let's copy the public key so we can paste it into GitHub:

cat ~/.ssh/id_ed25519.pub

Copy the content displayed in the terminal.

5. Paste the key into GitHub

Go to GitHub and navigate to:

Settings > SSH and GPG keys > New SSH key

Give the key a name (e.g., “My laptop”) and paste the key you copied. Click Add SSH key.

6. Test the connection

In the terminal, run:

ssh -T git@github.com

The first time, it may ask whether you want to continue connecting. Type yes. If everything is right, you'll see a message like:

Hi seu-usuário! You've successfully authenticated, but GitHub does not provide shell access.

That's it! You can now work with GitHub repositories securely, without typing your password on every push.

Conclusion

Linking your SSH key to GitHub is an essential step for any developer who wants efficiency and security in their workflow. It may seem a bit technical at first, but once you've done it, it becomes a natural part of your routine.

It's one more step toward making your development environment more professional and productive.

If you'd like to automate this process across multiple machines or learn how to protect your keys, stay tuned to the Forcoder blog — we'll soon be bringing advanced content on SSH, authentication and Git security.

Categories:

Keep reading

Practical Guide: Understanding Routers, Switches, Firewalls and Access Points

The foundation of any network infrastructure, whether home or corporate, lies in the devices that connect, control and protect data traffic. Routers, switches, firewalls and access points are the four pillars of that structure, yet it's still common to see questions about what each one does, how they…

Essential Network Protocols: TCP vs UDP, DNS, DHCP, FTP, SSH, and HTTP/HTTPS

Have you ever stopped to think about what happens behind the scenes when you visit a website, log in to a remote server, or simply connect your computer to Wi-Fi? All of this is only possible thanks to a set of network protocols, which work as universal rules and languages so that different…

Have a project in mind? Let's make it happen.

Custom websites, systems and integrations, focused on results. Tell us what you need and the Forcoder team will get in touch.