Friday 17 June 2016

GIT error - Permission denied (publickey) | while GIT clone, pull or any action

While running the GIT clone

git clone ssh://git@exdomain.com:7999/expro/exrepo.git

You might land into the error -

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This error could be caused due to ssh key mismatch or unavailability in GIT Stash. To overcome the issue first we need to create the ssh key pair either it can be DSA or RSA by following the below steps:

  • First open the command prompt and go to ".ssh" directory -> cd .ssh
  • Then run "ssh-keygen"
  • leave empty at the file saved location. It will take default location.
  • Again leave empty and hit enter at passphrase
  • Now the ssh key "id_rsa.pub" file will be generated at .ssh directory
  • Copy the content of "id_rsa.pub" and paste in Stash -> Account Settings -> SSH Keys -> Add Key
  • Finally setup .gitconfig
    • git config --global user.name "Sriram Gunda"
    • git config --global user.email "Sriram.Gunda@xxx.com"