If you receive this message when attempting to clone a repository.

git@github.com: Permission denied (publickey)

This article assumes you’re using a Unix-based system like Linux, macOS, or Windows Subsystem for Linux.

Try the following:

eval "$(ssh-agent -s)"
# This command should output: "Agent pid [process pid]"

# Add your ~/.ssh/id_rsa.pub file to your GitHub keys if it's not already there
ssh-add ~/.ssh/id_rsa
# The command should output "Identity Added"