git github com permission denied publickey code example

Example 1: git clone permission denied (publickey)

// Run the following command to generate a key
// Press return to keep all default options
ssh-keygen

// By default the key will be saved to ~/.ssh/id_rsa.pub
// Copy the contents of this file and save it in the following location
// Gitlab: `User Settings > SSH Keys`
// GitHub: `Settings > SSH and GPG Keys`

// To test the SSH authentication use the following command
ssh -T [email protected]

Example 2: [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

git remote -v
git remote set-url origin https://github.com/USERNAME/REPO.git

Tags: