Introduction
Learn how to generate a pair of SSH keys.
Check if there's any already available
Open the terminal and list the content in .ssh/ located in your home folder.
ls ~/.ssh
Is there any *.pub file? The most popular and by order of preference:
Algorithm | Public key | Private key |
---|---|---|
ED25519 | id_ed25519.pub | id_ed25519 |
RSA | id_rsa.pub | id_rsa |
If there's a file, copy the content from the *.pub to your Git host service. The other file is your private key, only share with computers you use.
Generate the key
If you don't have a pair of SSH keys, create a new one, by typing in your terminal:
ssh-keygen -t ed25519 -C "<yourCommentHere>"
Or
ssh-keygen -t rsa -b 2048 -C "<yourCommentHere>"
You will be prompted to create a file to save the new key. Press enter to accept the default value.
After that there's a prompt to create a passphrase. You can simply hit enter to create the key without a password. If you ever want to update the password, you can do:
ssh-keygen -p f /path/my_ssh_key
Copy the content of your public key
To use the key with your git online service, you'll need to copy the content of the name_of_key.pub. Use your favorite text editor or simply type in the terminal and copy.
cat /path/my_ssh_key.pub
This is what you are going to use with your git online service.