Windows OS

How to Run ssh-add on Windows?

Secure shell (ssh) is used to securely log in to the account on a network using the generated key pair, which is encrypted using cryptography technique. More specifically, the “ssh-add” command is used to add the generated key-pair in the list of ssh-agent. If you are not familiar with the usage of the ssh-add command and want to know about it, then stick with us.

In this article, we will provide the procedure to run the ssh-add key in Windows

How to Run ssh-add on Windows?

In order to run the ssh-add key on Windows, you need to fulfill the prerequisites and follow the instructed steps below.

Prerequisites

Make sure you installed Git on your Windows; if you do not have it already, follow our dedicated link for Git installation and then add its path on Windows.

After fulfilling the given prerequisites, check out the given instructions.

Step 1: Launch Git Bash

Launch “Git Bash” using the Startup menu:

Step 2: Generate ssh Key-pair

Specify your email address in the given command to generate ssh key-pair:

$ ssh-keygen -t rsa -b 4096 -C [Your_Email_Address]

It will then ask to create the passphrase and re-enter it for confirmation:

The given output indicates that the ssh key-pair account is successfully generated.

Step 3: Start ssh-agent

Start the ssh-agent by using the command in the Git bash:

$ eval $(ssh-agent -s)

This will start the ssh-agent in Git Bash

Step 4: Run ssh-add Command

Now, add the generated ssh key pairs to ssh authentication agent, and enter the passphrase to proceed:

> ssh-add ~/.ssh/id_rsa

Step 5: Copy Public Key to Clipboard

Copy the public key to the clipboard to paste it into the GitHub account. To do so, execute the provided command on the Git Bash console:

$ clip < ~/.ssh/id_rsa.pub

As a result, the generated public key will be copied to the clipboard

How to Add a Public Key to GitHub Account?

Firstly, log in to your GitHub account, click on your profile icon, and select the “Settings” option from the drop-down menu:

In the opened window, write the title of your choice, paste the copied key, and click on the “Add SSH key” button:

As you can see the copied public key has been added successfully:

We have provided the details related to executing the ssh-add command on Windows.

Conclusion

In order to run the ssh-add key in Windows, first of all, you need to have Git installed and then add the Git path to the Windows environment variables. After fulfilling the prerequisites, generate the key pair with the help of the ssh-agent, and add the generated public key to the GitHub account. This manual taught you related to run the ssh-add key on Windows.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.