➜ / 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
-
Have Questions? Post them here!
More Posts related to Git,
- How to ignore files in git using .gitignore file
- How to update expired GitHub token on local git remote config
- How to undo last Git Commit on Local Repository?
- Git Commit - Author identity unknown, Please tell me who you are email
- Git: Step-by-Step - How to Push Local Brach to GitHub
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- Remove git config at Local, Global or System Levels?
- Change the default git branch name from master to main
- fix fatal: --local can only be used inside a git repository error
- Git Remove Untracked Files using Command
- How to remove or unstage a file from git staged area
- Fix Git: Warning: could not find UI helper GitHub.UI on Windows
- Fix [oh-my-zsh] Cant update: not a git repository
- Get List of all local branches git command
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- [fix] fatal: this operation must be run in a work tree in git
- How to Install Git on Windows
- Perform an Empty Commit in Git without anything in Staging Area
- Rename git branch on Local and GitHub Remove using Command
- Fix: error: could not lock config file /etc/gitconfig: Permission denied
- Get the file location of git config values
- Git: Delete Branch Locally and Remotely at Origin
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- Github: How to Invite Collaborators
- How to change directory in Git bash
More Posts:
- [Fix] Restricted View permission level missing in SharePoint Online site library - SharePoint
- Check SSH/OpenSSH version Command - Linux
- What does has notifications silenced in Messages App mean in iPhone - iOS
- Save Java Object as JSON file using Jackson Library - Java
- [javaScript] Convert text case to lowercase - JavaScript
- How to check if Java main thread is alive - Java
- Steps to Compare Two files in Sublime Text Side-by-Side - Sublime-Text
- AW3 CLI command to get list of all region names - AWS