0

Currently I have a problem that when I want to clone ssh-link from GitHub: it writes to me that permission denied (publickey).

I know exactly that before I accidentally wrote answer "No" on the question If I am sure to continue with connecting.

Please, how could I unblock it? I mean, to change to status - Yes, and then it could be working as well.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

The "yes/no" question the first SSH connection is normally the one to add the remote host fingerprint to your ~/.ssh/known_hosts.


Warning March 2023:

"GitHub has updated its RSA SSH host key"


You can restore it with:

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

(note the >>, not >, to *append to your ~/.ssh/known_hosts file)

Compare the result of that command with the official SSH host keys from GitHub, to make sure you are talking to the "right" github.com.

A safer alternative to add those keys, using jq:

curl --silent https://api.github.com/meta \
  | jq --raw-output '"github.com "+.ssh_keys[]' >> ~/.ssh/known_hosts

After that, if you still have a permission denied, make sure you have added your public key to your GitHub SSH settings.

Test your connection with ssh -Tv github.com: you should see a welcome message:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250