Node Js - Setting up SSH keys for secure connection with the server
SSH (Secure Shell)
The SSH protocol builds a secure connection between a client and a server and protects against attacks in the network.
For more details about the SSH, read from the link: www.ssh.com
Create a new SSH Key
1. Open Git Bash (for Windows user)
2. Run the command in the Git Bash
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
The above command will prompt a question "Enter file in which to save the key". Press enter to take the default path.
3. Now It will prompt you "Enter passphrase".
To add an extra layer of security to your SSH key, you can add a passphrase.
For default, press Enter. The new SSH key should be added now.
Check the installed SSH key in your system:
Use the command: ls -a -l ~/.ssh
id_rsa is the private key which you will keep in your system only and will not share it with anyone.
id_rsa.pub is the public key which we share with the servers like GitHub so that we can make a secure connection with the server.
Anyone with a copy of the public key can encrypt data that can then only be read by the person who holds the corresponding private key.
Adding your SSH key to the ssh-agent
Steps:
1. Ensure the ssh-agent is running
Start the ssh-agent in the background using the command: eval $(ssh-agent -s)
Start the ssh-agent in the background using the command: eval $(ssh-agent -s)
2. Add SSH key to the SSH agent
ssh-add ~/.ssh/id_rsa
That's it. We have configured SSH keys for pushing our code to GitHub.
Note: Mac and Linux users can follow the steps given on this link: Github help.
0 Comments