Skip to content
Fix Code Error

How to solve Permission denied (publickey) error when using Git?

March 13, 2021 by Code Error
Posted By: Anonymous

I’m on Mac Snow Leopard and I just installed git.

I just tried

git clone [email protected]:cakebook.git

but that gives me this error:

Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

What am I missing?
I’ve also tried doing ssh-keygen with no passphase but still same error.

Solution

If the user has not generated a ssh public/private key pair set before

This info is working on theChaw but can be applied to all other git repositories which support SSH pubkey authentications. (See gitolite, gitlab or github for example.)

First start by setting up your own public/private key pair set. This
can use either DSA or RSA, so basically any key you setup will work.
On most systems you can use ssh-keygen.

  • First you’ll want to cd into your .ssh directory. Open up the terminal and run:

    cd ~/.ssh && ssh-keygen

  • Next you need to copy this to your clipboard.
    • On OS X run: cat id_rsa.pub | pbcopy
    • On Linux run: cat id_rsa.pub | xclip
    • On Windows (via Cygwin/Git Bash) run: cat id_rsa.pub | clip
  • Add your key to your account via the website.
  • Finally setup your .gitconfig.
    • git config --global user.name "bob"
    • git config --global user.email [email protected]
      (don’t forget to restart your command line to make sure the config is reloaded)

That’s it you should be good to clone and checkout.

Further information can be found at https://help.github.com/articles/generating-ssh-keys (thanks to @Lee Whitney)
–

If the user has generated a ssh public/private key pair set before

  • check which key have been authorized on your github or gitlab account settings
  • determine which corresponding private key must be associated from your local computer

eval $(ssh-agent -s)

  • define where the keys are located

ssh-add ~/.ssh/id_rsa

Answered By: Anonymous

Related Articles

  • Permission denied (publickey). fatal: The remote end…
  • Problems Installing CRA & NextJS from NPM…
  • Git's famous "ERROR: Permission to .git denied to user"
  • I need to extract working hour breaks out of a Time…
  • Permission denied (publickey) when deploying heroku…
  • Migration of repo from Bitbucket to Gitlab does not…
  • Spring Boot - Cannot determine embedded database…
  • Maven2: Missing artifact but jars are in place
  • SSH Key: “Permissions 0644 for 'id_rsa.pub' are too…
  • Specify an SSH key for git push for a given domain
  • Composer is using https instead of ssh (for GitLab)
  • Git - Pushing code to two remotes
  • Vue.JS & Spring Boot - Redirect to homepage on 404
  • How can I exclude all "permission denied" messages…
  • npm ERR! fetch failed status code 502
  • Why am I getting a "401 Unauthorized" error in Maven?
  • key_load_public: invalid format
  • Rails wrong number of arguments error when…
  • Repository access denied. access via a deployment…
  • Is it possible to use pip to install a package from…
  • Masked variables when overriding service commands are empty
  • How do I force Maven to use my local repository…
  • SecurityException: Permission denied (missing…
  • Git: Permission denied (publickey) fatal - Could not…
  • The remote end hung up unexpectedly while git cloning
  • How can I find the location of origin/master in git,…
  • unable to deploy next js to azure
  • Why do git fetch origin and git fetch : behave differently?
  • SSH Private Key Permissions using Git GUI or…
  • Git, fatal: The remote end hung up unexpectedly
  • Git Using Remote Branch
  • Baffling variadic templates exercise
  • Why call git branch --unset-upstream to fixup?
  • Jenkins with nginx using docker Port 50000 config
  • Git push error: "origin does not appear to be a git…
  • How to filter a RecyclerView with a SearchView
  • Git error: src refspec master does not match any
  • Completely uninstall PostgreSQL 9.0.4 from Mac OSX Lion?
  • GLYPHICONS - bootstrap icon font hex value
  • Import an existing git project into GitLab?
  • fatal: does not appear to be a git repository
  • Python File Error: unpack requires a buffer of 16 bytes
  • How to add a jpa repository in bean for spring mvc?
  • How do I clone a single branch in Git?
  • GIT clone repo across local file system in windows
  • 'cannot open git-upload-pack' error in Eclipse when…
  • typescript - cloning object
  • Android "gps requires ACCESS_FINE_LOCATION" error,…
  • Why do I have to "git push --set-upstream origin "?
  • SSL certificate rejected trying to access GitHub…
  • UnsatisfiedDependencyException: Error creating bean…
  • Is it safe to shallow clone with --depth 1, create…
  • Jenkins returned status code 128 with github
  • how to integrate selenium driver for chrome and…
  • Clone private git repo with dockerfile
  • Postman gives 401 Unauthorized - Spring Boot & MYSQL
  • How do I push a local repo to Bitbucket using…
  • How to save public key from a certificate in .pem format
  • What's the difference between git clone --mirror and…
  • Push on GIT and Bitbucket
  • Getting permission denied (public key) on gitlab
  • Autowiring fails: Not an managed Type
  • What is and how to fix…
  • How to track untracked content?
  • Calculate RSA key fingerprint
  • Unable to ssh into QNX 6.5.0 VirtualBox session
  • How do I avoid the specification of the username and…
  • How can I show current location on a Google Map on…
  • HQL Responding with…
  • AWS ssh access 'Permission denied (publickey)' issue
  • Error: request entity too large
  • Git push: "fatal 'origin' does not appear to be a…
  • GitHub: Permission denied (publickey). fatal: The…
  • How can I find the product GUID of an installed MSI setup?
  • Git Permission denied (public key) but public key is…
  • Error creating bean with name
  • How can I clone a private GitLab repository?
  • Disable password authentication for SSH
  • Adding a public key to ~/.ssh/authorized_keys does…
  • Git SSH error: "Connect to host: Bad file number"
  • org.hibernate.MappingException: Could not determine…
  • What is C# analog of C++ std::pair?
  • How to request Location Permission at runtime
  • Gitlab CI deployment failed: "bash: pm2: command not…
  • Git error: "Host Key Verification Failed" when…
  • Unexpected behaviour java priority queue. Object…
  • Android M - check runtime permission - how to…
  • Managing SSH keys within Jenkins for Git
  • How to check the version of GitLab?
  • How do we change the URL of a working GitLab install?
  • How can I remove an SSH key?
  • error: RPC failed; curl transfer closed with…
  • What does "Fatal error: Unexpectedly found nil while…
  • Change a Git remote HEAD to point to something…
  • SDL_SetRenderTarget() hangs for a while if multiple…
  • Maven Could not resolve dependencies, artifacts…
  • Git workflow and rebase vs merge questions
  • What is "git remote add ..." and "git push origin master"?
  • Git : fatal: Could not read from remote repository.…
  • Undo Gerrit push on GitLab

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to add images to README.md on GitHub?

Next Post:

Parsing JSON with Unix tools

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error