Creating SSH Keys For Github From Windows

Creating SSH Keys For Github From Windows

In this article, you will learn how to add Secure Socket Shell (SSH) to your GitHub account so you can access our repository quickly and easily without repeatedly inputting your email and password.

To check if an SSH Key already exists open Git Bash and type ls -al /.ssh to list every file in the root directory that ends in .ssh.

If you receive an error, it means the file does not exist, and you will need to create a new one. Check the directory listed below to see if you have any of these filenames in the directory folder with public keys.

id_rsa.pub
id_ecdsa.pub
id_ed25519.pub

Generating new SSH Keys

To enable easier authentication, you will create a new SSH on your local machine and connect to your GitHub account. Copy the lines below into your Git Bash window while replacing the email with your GitHub email address.

$ ssh-keygen -t ed25519 -C "your_email@example.com"

If you experience a system error caused by legacy support, try these steps:

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This will create a new SSH with the provided GitHub email.

> Generating public/private ALGORITHM key pair

Either use the default location, which is advised, or switch to a different file location of your choice by pressing Enter.

> Enter a file in which to save the key (/c/Users/YOU/.ssh/id_ALGORITHM):[Press enter]

A secure passphrase that can only be used by you will now be required for authentication. Additional details regarding SSH Key passphrases are provided below.

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

Connecting your SSH key to the ssh-agent

If you already have GitHub Desktop installed, you may skip cloning and pushing to the repository using SSH Keys. It is crucial to validate SSH exitance before adding an ssh-agent.

Now, you may manually launch your ssh-agent by executing

# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566

The next step is to add your ssh agent with this command.

$ ssh-add ~/.ssh/id_ed25519

Adding SSH keys to your GitHub account

Let's transfer your SSH public key to your clipboard. If you changed the existing configuration, be sure to modify the filename.

If using the clip does not work for you, you may locate the.ssh file by turning on the hidden view on your system and copying it to the clipboard.

Log into your GitHub account and go to the top-right corner of the website. Select Settings from the dropdown menu after clicking on the user profile.

image

Click New SSH key from the sidebar area of the SSH and GPG keys.

image

Fill in the "Title" area with a meaningful name of your choosing, such as "home laptop," then choose "either authentication or signing" as your key type and paste your key into the "Key" field as shown below.

image

To conclude the configuration, choose Add SSH Key and you might need to input your login password again.

image

Your SSH keys will now be used to authenticate with GitHub for all of your push and pull requests.

Reference Using SSH Protocol by GitHub