➜ / git clone git@github.com:github-username/repo.git
Cloning into 'c2c-2022'...
The authenticity of host 'github.com (13.234.176.102)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wxyV6TuJJhbpZisF/zLDA0zX2A4KZJHY2.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Fix: Solution 1
The most common reason is you are trying to clone the GitHub repo locally and you have not set the access tocken
Steps to set github access token
- Click on your profile icon on github.com,
- Now click on Settings,
- Scroll down and select Developer settings from the left side menu options,
- Now click on Personal access tokens,
- Now click on the button Generate new token

Github generate new personal access token - You will be prompted to enter your github.com password again,
- Now you will need to add a note to tell what the token will be used for (this token acts like an OAuth token and can be used for API authentication using basic auth. You can also set the expiration for the token from 7 days to 30 days or never expire.
- Now you can select the scope of the token, I have set repo: "Full control of private repositories"
- Now click on Generate Token button
- You should be able to see your token now, copy it.
Do make sure to copy your personal access token on the page as you will not be able to see it again!
% git clone https://<Personal-token>@github.com/<user-name>/<repo-name>.git
Cloning into 'git-repo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Fix: Solution 2
The better way is to generate an SSH key locally and add it to the GitHub Settings,
- Open local terminal and run the below command with the email setup with your GitHub account,
ssh-keygen -t ed25519 -C "name@domain.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/root/.ssh/id_ed25519): githubkey Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in githubkey Your public key has been saved in githubkey.pub The key fingerprint is: SHA256:uxABXYZOK4grihAz7B3Afhv3/tanAb7axtjh2BRo4H+Y name@domain.com The key's randomart image is: +--[ED25519 256]--+ |.o.o++.o .. | |o.o+oo= . o. | |+o. +o. .o. . | |+. o.. . ..E | | .. .S o . ... | | . + + ... | | o .. o.. | | . oBoo. | | ..ooB= | +----[SHA256]-----+ - Add the SH key to the ssh-agent:
% eval "$(ssh-agent -s)" % ssh-add ~/.ssh/githubkey - Now add the ssh key to your GitHub account: cat ~/.ssh/githubkey.pub copy the text,
- Go to GitHub.com account, click on your profile picture and select Settings,
- Now click on SSH and GPG keys,
- Click on button New SSH key
- Add the copied .pub file content into key text area.
- Click Add SSH key
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!