how to create SSH GitHub

How to Generate SSH Keys for GitHub

Let’s say you want to contribute to WordPress. Want to be part of the open-source world and share your skills with the community? For that, you have to clone the WordPress developer version from Github. Now you can do this either using HTTP or the SSH Github key.

Github WordPress repository
WordPress GitHub repository

Now the question must be asked: do you need a SSH key for Github or will HTTPS be okay? Before we learn the SSH key generation, let’s understand why you need the SSH.

Github HTTP vs SSH

Github has three methods to clone a repository. The third one is Github CLI, which is highly beneficial for production-level automation. But we are talking about you who want to contribute to an open-source project.

That’s why we are going to consider only two: HTTPS and SSH. Let’s see what the differences are between these two.

Aspect SSHHTTPS
AuthenticationUses SSH keys for secure authenticationRequires a Personal Access Token (PAT)
SecurityGenerally considered more secureAcceptable for basic usage, but not as secure as SSH
Ease of SetupRequires initial setup of SSH keysSimple and straightforward
UsageRecommended for regular users and businesses dealing with sensitive dataSuitable for most users and basic Git operations
ConvenienceUses key files for authenticationRequires entering a password/token for each push
PortTypically uses port 22Uses port 443 (open in most firewalls)

From the table, we get an idea of which one is preferred for a more secure connection. The SSH key, which is a large encrypted string that contains letters and numbers, is much more secure. On the other hand, sharing your credentials just to clone a public repo might not be a good idea.

How SSH works on Github

SSH Kye ensures encryption using long strings, as we know already. But it’s not just one, but a pair of keys. In the case of Github, one key is generated for your local system, and another is a public key.

SSH keys on Github connected to server match each other

The private key will be stored on your device or on the server that you are connecting to. The public key will be on the Github account through which you will access the other Github repos.

In a nutshell, when you attempt to connect with a repo to clone, the two SSH keys check against each other. The keys match each other, only the connection is established, and you can clone the repository.

SSH key setup for Github

As we are talking about cloning the the WordPress developer version from Github, let try it first. Let’s see what we will see before creating SSH key.

Simple go to the terminal and type,

After the git clone command, the URL is copied from the wordpress-develop repo on Github. You will see the warning saying you don’t have any public SSH keys in your GitHub account.

Github SSH URL with warning says no SSH key

After you run the command, this will say the command is not found. Okay, now start creating the SSH key first.

Without SSH key

Generating a new SSH key

Our goal here is to create the key in a secure folder called “.ssh.” This will allow the remote server to access the key without asking for the passphrase (which is basically the password) every time.

Usually the folder will be on your device, but if not, you can create one using the below command and then run the above command.

To create the SSH key on your terminal, type the below command. Please note that this will work on any operating system.

Change the email to your personal Github account email, by which you will access Github to clone the repo.

Github SSH Key name

Now it will ask for the name of the ID. You can give any name you want. But if you enter the bank, it will be id_rsa by default.

Github SSH Key Passphrase

Then it will ask you to enter a passphrase and ask again to confirm.

GitHub SSH Key Generated

If everything is correct, then you will see this. With the name of the SSH keys. Yes, it will create two keys: one is private and the other is public. The public one will have the extension .pub in it.

To read these files, you can use the below command. Here my key name is abir-mac. You have to put yours.

Mac and Linux

Windows

SSH Key Public Private

Install public key on Github.com

Now let’s add this key to your GitHub account. The process is very simple. Go to the settings in your GitHub account, then go to the SSH and GPH keys.

Setup SSH setup on github

After that, click on the “New SSH key” and enter the title of the public SSH key file with .pub extension. Now access the .pub version of the key and copy that from the terminal. In the key input section of Github, paste that key and click “add SSH key.” The key type should be “Authentication Key.”

SSH key add in github

SSH key linked

SSH Config

One more thing you have to do if you gave the key a custom name; otherwise, you skip this step. You have to configure the key. To do so, in your terminal, type the below command:

Github SSH Config

This will open the configuration interface in the terminal. Now add the below line there.

Change the “abir-mac” with your given name here. Now in the MacOS terminal, press Ctrl+X, then press Y and return. The system config file is saved now. That’s it. Now, if you run the git clone again from the terminal, it will definitely start the cloning process.

You can also test it to see if it’s working or not using the below command.

Wrap up

Github is a fantastic tool for developers to share their work with others. And that’s not it; as we all know, it is a version control tool for production. But if you can unlock its full potential, you have to ensure security and ease of use. And that’s where the key of SSH GitHub comes in. Happy coding.

Tired of buying addons for your premium helpdesk?

Start off with a powerful ticketing system that delivers smooth collaboration right out of the box.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Get support insights directly in inbox!
Blog subscribe form
Fluent Support
Best AI-Powered Helpdesk in WordPress