So the first question comes in mind
what is the public-private key?
In simple words, it is a cryptographic key-based authentication to make sure the connectivity between two pairs are encrypted.
Mostly the ssh key pairs are used in ssh, sftp or git.
The key when we generate it’s great to key pair one is public and one is private and those two key pairs work together to make sure the communication it’s encrypted.
The best working scenario we can say if we are trying to access any server via ssh or sftp and there are multiple accounts for people who want to access the services rather than creating accounts for sharing password we can use one account and create ssh key pairs for each person who wants to access that’s why we don’t need to share password between multiple users.
How key authentication works ?
When we generate keys its comes with the public key and private key the public key it’s used to share with the services or a person which can be used to encrypt data that cannot be decrypted without a private key.
In Linux or Mac Operating System The Terminal support ssh command but Windows we need to use third-party software air to create public and private keys I will show two methods that we can use in Windows to generate public and private key pairs.
How to generate a public-private key using putty ?
Putty is a good option for Windows users when they want to access any ssh based terminal for example networking switch or any VPS server.
Open Browser and navigate to the putty website: https://putty.org/ Click on the download here link
There are Multiple Link and single binaries available on the putty download website but for our, we will download a 64-bit installer as it will have all the required package. My System is running on 64-bit architect
If you not sure which system architect you running go-to Control Panel > System and Security > System where you can see System Type.
After download run the file for installation setup is simple next > next > finish type there is no manual customization required.
After installation press start key and type “puttygen” and open application
Now all we need to click on the generate option. Don’t worry about all other options right now it’s not required for this basic Key generation.
Now all we just need to move the mouse cursor on the big black area randomly which fill the progress bar.
After Successful generation just click on Save Public and Save Private Key. We need to save both keys
I am saving on my desktop name (PublicKey.txt) and (PrivateKey.ppk), Now when open Public key files its looks like following.
How to generate a public-private key using GIT Bash ?
GIT is well-known repository version control services among the developer so this option is good for the users Who use git services by default kit package comes with a GIT terminal that can be used to Generate ssh keys.
Download GIT and Bash Visit following website https://git-scm.com/ click on download link.
The installation is straight forward but there’s some configuration which we can quick as per our requirement, for example, GIT installation use a default editor which we can set as we required, for example, I am using Notepad plus plus as my default notepad so I Selected notepad plus plus from the drop-down list
Rest settings leave as the default just click next > next > and finish. After installation click on the start menu and type Git Bash and open the application.
GIT Bash, it is the same Linux terminal client so we can use all Linux command here for example to generate ssh keys we can use command
Keygen procedure ask you where you want to save the file by default path is your user profile and it will create one hidden directory name message save the keys if you want you can change the file path but to use with the kit and other ssh services it’s better to leave the path as default.
Once all things are successful it will show you do the terminal again.
To identify the following keys has been saved in your computer you cannot navigate on the following locations
Your private key has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
View public key just use the following command
Or from Run menu type following and open keys in notepad.