Generate ssh key in mac and add to Github

To interact with a GitHub repository and check in your source code , you typically authenticate yourself by providing your username and password. However, using an SSH key is another authentication method that eliminates the need to enter your credentials each time.

SSH keys consist of a public key that is shared with services such as GitHub, and a private key that is stored solely on your computer. If the keys correspond, access is granted.

In this blog post, we will discuss how to generate an SSH key on a Mac and then update it in GitHub so that you can check in your code from your system.

Step 1- Paste the below cmd into your terminal and run

ssh-keygen -t rsa -b 4096 -C "[email protected]"

This creates a new ssh key, using the provided email as a label

Generating public/private rsa key pair.

Step 2- When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.

Enter file in which to save the key (/Users/Your user name/.ssh/id_rsa): 

Step 3– At the prompt, type a secure passphrase or you can leave it blank then enter.

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

Step 4– Copy your generated pub key .

pbcopy < ~/.ssh/

This command copies the contents of the file to your computer’s clipboard.

Step 5– Let’s add ssh key to your github account .

To access the Settings page, click on your profile photo in the top-right corner of any page, and then select “Settings”.In the user settings sidebar, click SSH and add keys.

Leave a Reply

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