Skip to content

Instantly share code, notes, and snippets.

@kyudorimj
Last active February 10, 2022 04:40
Show Gist options
  • Save kyudorimj/40c43b01d459f5b8ede66e47235e2907 to your computer and use it in GitHub Desktop.
Save kyudorimj/40c43b01d459f5b8ede66e47235e2907 to your computer and use it in GitHub Desktop.
GENERATE SSH KEY

HOW TO GENERATE SSH KEY

Listed here are the commands to generate and register ssh key on your computer.

Generate the SSH Key

ssh-keygen -t rsa -b 4096 -C <your email address here>

You can specify the path where you want to save the ssh key by typing the path when it is asked. Not typing anything will generate the key inside .ssh folder in the home directory.

After saving the key, you will be ask to enter a paraphrase, you will use this paraphrase later to access the key. You can click enter for empty parahrase but it is not recommended.

Check if the SSH Agent is already running

eval $(ssh-agent -s)

The ssh-agent is a helper program that keeps track of user's identity keys and their passphrases. The agent can then use the keys to log into other servers without having the user type in a password or passphrase again. This implements a form of single sign-on.

Add the SSH Key to the SSH Agent

ssh-add ~/.ssh/id_rsa

~/.ssh/id_rsa is the path where the ssh key is saved. If you specify a path earlier, you need to add that ssh key.

View public key using the cat command

cat ~/.ssh/id_rsa.pub

This will output your generated SSH key earlier. You can copy this key and paste in on github, server or anywhere that you need to access remotely through ssh.

References:

How to Push code to Github: https://youtube.com/technicalbabaji/how-to-push-to-github/
How to Generate a SSH Key: https://docs.githbu.com/how-to-gen-a-key/
ssh-agent - How to configure, forwarding, protocol https://www.ssh.com/academy/ssh/agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment