Generating new SSH keys for your github

Generating new SSH keys for your github

If you don't already have an SSH key, you must generate a new SSH key to use for authentication.Probably you have encountered this error if you've been using password to aunthenticate git operations and now its time we generate SSH keys for your github.

Support for password aunthentication was removed on August 13,2021.Please use a personal access token instead

Lets get started.

1.Open Git Bash and confirm that you're in the home directory.It looks something like this

cm_amos@DESKTOP-404 MINGW64 ~
$ pwd
/c/Users/123

2.Paste the text below, substituting in your GitHub email address.

$ ssh-keygen -t rsa -C "put_email_here"

3.When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

4 At the prompt, type a secure passphrase. A passphrase is like a password.Choose a good passphrase.

5.You will find the key in the .ssh directory(notice the key ,its a .pub file)

Use any commad line editor to open the file ,copy the key and close the file immediately after copying the key.Take precaution not copy extra spaces.

For simplicity type/copy this command in your terminal to copy the key.

$ clip < ~/.ssh/id_rsa.pub

Add generated SSH keys to Github account

1.Go to Github

2.Login to your account

3.Navigate to settings

4.Go to SSH and GPG keys

5.Click on new SSH key button

6.Choose a Title of your choice and paste the key in the key text field and click on the Add Key green button

github-add-ssh-key.png

7.You will be prompted to input your password for your key to be added to github.

Adding your SSH key to the ssh-agent

1.Start ssh-agent in the backgroung

$ eval "$(ssh-agent -s)"

2.Add your SSH private key to the ssh-agent.

$ ssh-add ~/.ssh/id_rsa

3.NOTE:You will be prompted to enter your passphrase before the SSH key is added to ssh-agent

Enter passphrase for /c/Users/123/.ssh/id_rsa:

3.On success you will get a message like this

Identity added: /c/Users/123/.ssh/id_rsa (your_email_appears_here)

Now we have generated SSH keys and added them to your github account and ssh-key agent.While adding the remote origin always remember to copy the link for SSH and not https.

Thanks for reading my blog,see you in my next Blog.Keep coding