Gitlab push failed for Permission denied (publickey) fixing

Create a project inside gitlab and push from local pc file is a simple way before some a days. But  now some security reason held and make extra protection to submit project data in git repository.
I already faced this problem and googling a lot for solution. In this case I always try to have solution from gitlab.com or some authorized website. The process is most complex and tough. After all i follow most of them and why and how this process working can not understand at all.

I am now going to represent process of fixing this issue. First of all I make this step by step for batter understanding.


  1. Go to "Git Bash" just like cmd. Right click and "Run as Administrator". 
  2. Type ssh-keygen Press enter. 
  3. It will ask you to save the key to the specific directory. 
  4. Press enter. 
  5. It will prompt you to type password or enter without password. 
  6. The public key will be created to the specific directory. 
  7. Now go to the directory and open .ssh folder. 
  8. You'll see a file id_rsa.pub. Open it on notepad. Copy all text from it. 
  9. Go to https://gitlab.com/profile/keys . 
  10. Paste here in the "key" textfield. 
  11. Now click on the "Title" below. It will automatically get filled. 
  12. Then click "Add key". 


Now give it a shot and it will work for sure.


Have you complete this full process properly? If answare is yes, check problem already solved. Having trouble to apply process or can not batter understanding what and how to do? Yes you have also solution. Now i will discuss about the simplest and effective way. Just follow below instruction.

There is a very simple solution to this: instead of working with ssh - move to https. to do this: in your project folder you have a .git folder in there - you have a config file - open it in a text editor and change the line

url = git@gitlab.com:yourname/yourproject.git

 to

url = https://gitlab.com/yourname/yourproject.git

most of the time I use this second method and it work properly. I think your problem also solved. Please comment and give your feedback.