I try setup my Github Ssh key by follow step from https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account. At first everything works OK.
But after restart my computer, using git repository gives error : Error: Permission denied (publickey).
I create a new Github repository run git clone, but it still return the same error.
>Solution :
Seems a duplicate of Git: How to solve Permission denied (publickey) error when using Git?
- Ensure the ssh-agent is running by running
eval $(ssh-agent -s)
- Add the key by running
ssh-add ~/.ssh/{key_name}
where key_name is your key file name you generated (example: id_ed25519) - You may want to consider creating or appending below to
.ssh/config
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/{key_name}