Generating a new SSH key
- Open terminal and paste the text below, substituting in your GitHub email address.
ssh-keygen -t ed25519 -C "your_email@example.com"
When you’re prompted to “Enter a file in which to save the key”, you can press Enter to accept the default file location. Please note that if you created SSH keys previously, ssh-keygen may ask you to rewrite another key, in which case I recommend creating a custom-named SSH key. To do so, type the default file location and replace id_ssh_keyname with your custom key name.
- At the prompt, type a secure passphrase.
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
Adding your SSH key to the ssh-agent
- Start the ssh-agent in the background.
eval "$(ssh-agent -s)"
- Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
ssh-add ~/.ssh/id_ed25519
Add the SSH key to your account on GitHub.
- Copy the SSH public key to your clipboard.
cat ~/.ssh/id_ed25519.pub
Then select and copy the contents of the id_ed25519.pub file to your clipboard
- Go to SSH and GPG keys
- click New SSH Key
- on the next page, paste your SSH key
- Click Add SSH Key
- If prompted, confirm access to your account on GitHub.