SSH or HTTPS connection to GitHub

Why are we doing this?

We need to connect to Github (or whatever other repository we may be using), and for that to work, we have to be able to identify ourselves. This is actually a pretty hard thing to do, and there are two main options we have.

What are the options?

This is recommend if you are on Linux or macOS (HTTPS also is recommended on macOS). (It does work on Windows, but since the HTTPS method is included by default, you may as well use that instead.)

Secure SHell is the standard program for connecting to remote servers. It’s well worth learning anyway.

These days, every major operating system has it built in, but it requires more set up using “SSH keys” to use it for Github. It’s really useful to set this up and get to know it well, even for things other than git.

You should remember your choce for the lessons.


Based on your decision above, try to set it up. You can try the other one if your first choice doesn’t work. There’s nothing wrong with doing both of them.

Watch this in video form

This CodeRefinery video about ssh keys (7 min) shows how to set up SSH connection to GitHub. If you are new to SSH keys, We recommend you watch this first to understand what is going on.

For the instructions, please follow this guide from GitHub to connect to GitHub with SSH keys. These same instructions work with services other than GitHub as well (except the adding the key to GitHub part).

How to verify that it worked

Try this in your terminal shell:

$ ssh -T

If you set up ssh keys correctly, you will see:
Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.

If it says “You’ve successfully authenticated” then it works and your SSH keys are properly set up with GitHub.

You possibly see this warning (the IP and the fingerprint may look differently):

$ ssh -T

The authenticity of host ' (' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Before typing “yes”, verify that the fingerprint is one of these.

What this means: SSH is a secure protocol to send data between two computers but the very first time you ever connect to the remote host, SSH asks if this is really the host/server we meant to talk to and to verify that nobody is trying to impersonate the other host. Once we validate the connection, SSH will remember that we trust that host and not ask this question again.