Before you start generating keys like a hacker in a movie montage take a deep breath and look in your home directory for an SSH folder. Typical files are ~/.ssh/id_rsa
and ~/.ssh/id_ed25519
. If one of those exists you can skip key generation and move on to adding the key to an agent and uploading the public part to GitHub.
Use a modern algorithm so future you does not hate past you. Ed25519 is a solid choice unless your organization demands legacy keys. Run this in a terminal and follow the prompts.
ssh-keygen -t ed25519 -C "your_email@example.com"
If you prefer RSA for some reason use a large size. Otherwise accept the default file name and set a passphrase if you want an extra layer of misery protection.
The SSH agent stores your unlocked key so Git can use it without you typing the passphrase every five minutes. Start the agent and add your key.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
Check the agent has your key with ssh-add -l
. If you see nothing then the agent is not running or the key was not added.
Copy the public key file such as ~/.ssh/id_ed25519.pub
and paste its contents into your GitHub profile under SSH and GPG keys. Give it a human readable name so the person who inherits your machine in ten years does not cry.
Make sure your repository remote is using SSH and not HTTPS. Run git remote -v
and look for an SSH style entry described as git at github dot com followed by user slash repo dot git. If it shows HTTPS then change the remote to an SSH URL so publickey authentication is used.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
Strict permissions matter because SSH will refuse to use keys that are world readable. Also be aware of multiple SSH agents or credential helpers that can interfere with which key is offered.
Talk directly to GitHub to see what the server thinks of your key. The verbose flag spits out the useful garbage that tells you whether the key was offered or ignored.
ssh -T -v git@github.com
Read the debug output for lines that show which identities were tried and whether an agent supplied a key. Common failure causes include the wrong key being used missing the key on GitHub or file permission problems.
ssh-add -l
to see what the agent is offering~/.ssh/config
with Host entries to force the right key for github dot comIn short check for an existing SSH key generate a modern key if needed add it to an SSH agent upload the public key to GitHub ensure your Git remote uses SSH secure your file permissions and run an SSH debug session. Follow those steps and the permission denied publickey error should stop haunting your commits. If it does not then the problem is probably something silly like a mismatched key or an agent you forgot to start.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.