- What are SSH Keys?
- How To Set Up SSH Keys?
- Create an SSH key on Mac and Linux
- Create an SSH Key on Windows
What are SSH Keys?
SSH keys are an access credential used in SSH protocol (Secure Shell). A secure shell is a network protocol, which helps to login from one computer to another securely, as well as to manage networks, operating systems, and configurations. Functionally, SSH keys are nearly the same as passwords, but it’s more secure to log into a server with SSH keys than use only passwords because decrypt SSH is very difficult, almost impossible.
SSH keys always come in pairs, and each of these pairs is composed of a public key and a private key. These two are types of keys.
- Public keys, also known as authorized keys, determine who can access each system.
- Private or identity keys identify users and give them access.
How To Set Up SSH Keys?
Create an SSH key on Mac and Linux
As these two operating systems have modern terminal applications, that combine with SSH package, the steps of creating an SSH key are the same for both of them.
- Open a command terminal and run the following:
ssh-keygen -t rsa -b 4096 -C "email@example.com"
- Then you have to choose the file location.
> Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
- Then you should add a secure passphrase, which will be required any time the SSH key is used.
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
- Add the new SSH key to the ssh-agent
The ssh-agent is a tool responsible for holding private keys, but it also arranges requests to sign SSH requests with the private keys for security purposes.
Execute the following code to make sure that the ssh-agent code is running:
eval "$(ssh-agent -s)" Agent pid 59566
If the ssh-agent code is running, add the new SSH key to the local SSH agent by executing the following command:
ssh-add -K /Users/you/.ssh/id_rsa
Create an SSH Key on Windows
You need Git Bash to create an SSH key on the Windows operating system. If you have it, you can generate the key following the same steps as given above.