Skip to content

Instantly share code, notes, and snippets.

@1eedaegon
Last active October 5, 2021 17:48
Show Gist options
  • Save 1eedaegon/cb59e17535c5334dd9131b8a1fcc0b6d to your computer and use it in GitHub Desktop.
Save 1eedaegon/cb59e17535c5334dd9131b8a1fcc0b6d to your computer and use it in GitHub Desktop.
git clone or git pull authentication failed
# How to set github on MacOS
# First if you use wsl2 ubuntu, try this: git.exe clone [remote-repo]
# Or git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"
# 1. Generate public key
$ ssh-keygen -t ed25519 -C "your_email@example.com"
# 2. Copy to clipboard public key
$ pbcopy ~/.ssh/id_ed25519.pub
# 2-1) if on Ubuntu
$ xclip -selection clipboard < ~/.ssh/id_ed25519.pub
# 2-2) if on Ubuntu wsl2
$ cat ~/.ssh/id_ed25519.pub | clip.exe
# 3. Add public key on github account
- 1) https://github.com/settings/keys
- 2) Click "New SSH Key"
- 3) Paste clipboard on "key"
- 4) Click Add SSH Key
# 4. Test connection ssh
$ ssh -T git@github.com
> The authenticity of host 'github.com (IP ADDRESS)' can''t be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)?
$ yes
$ Hi [YOUR_NAME]! You've successfully authenticated, but GitHub does not provide shell access.
# 5. Set remote repository using ssh
$ git remote set-url origin git@github.com:[repo-name].git
# 6. Happy git :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment