How To Generate SSH Key For Git?

0
70
How To Create SSH Key For Git

Today, you will learn how to generate SSH key for Git and add into GitHub. You can use any git repository hosting provider like GitHub, Bitbucket, GitLab, etc. Keep in mind that with using SSH as a cloning URL, you can get rid of entering credentials every time using this method.

# Step 1: Create SSH Key

Execute following command into Git Bash. Replace your email address.

ssh-keygen -t rsa -b 4096 -C "email@example.com"
Create SSH Key

# Step 2: Saving SSH Key To Path

After executing above command will ask you to enter file in which to save the key. Use default and press enter.

File Path To Save

Next, it will ask you to enter a password. Press enter to leave it blank. Similarly, do it for the enter the same password prompt too.

Key Generated

# Step 2: Adding SSH Key To SSH Agent

After, creating and saving SSH Key, ensure the ssh-agent is running.

eval "$(ssh-agent -s)"

Running above command will return pid.

Ensuring Agent Id Is Running

Finally, add SSH key to agent by executing.

ssh-add ~/.ssh/id_rsa
Identity Added

SSH key is now generated successfully.

# Adding SSH Key In GitHub (Bitbucket, GitLab)

After setting up your SSH key, login into your GitHub account. Click on your profile picture at the right top and click settings.

Git Hub Profile Click

After that, click on SSH and GPG keys.

SSH and GPG keys

Add new SSH key by clicking New SSH Key button.

New SSH Key in github

Go to C:\Users\user-name\.ssh path. Open id_rsa.pub in notepad. Copy whole content and paste it into GitHub new SSH key section. Click on add new button.

Key Added

That’s it! You learned how to generate SSH key for Git and add it into GitHub. From now, you can use SSH as a cloning URL, and you don’t need to enter a password every time, whenever you push data.

Learn more about Git.

Previous articleWhat Is Accessors & Mutators In Laravel?
Next articleHow To Clone A Git Repository?
Welcome to the world of web development, where technology and creativity come together to bring ideas to life. My name is Keyur Gadher, and as a web development blogger, I am here to share my knowledge and experience with you. From front-end web development to back-end programming, I will provide you with valuable tips, tricks, and techniques to help you create beautiful and functional websites that are tailored to your specific needs. Whether you're a beginner or a seasoned pro, I am here to help you take your web development skills to the next level. Join me today and let's start coding!

LEAVE A REPLY

Please enter your comment!
Please enter your name here