GIT push: permission denied (public key)












33















GIT: I'm trying to push a file to a repo of a friend but errors on public key.



git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.


Where and how do we define public / private keys?



git remote -v returns:



origin  git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)


any help is appreciated.










share|improve this question


















  • 2





    possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

    – AD7six
    Oct 29 '13 at 14:23











  • Hi @wyguf, Please accept my answer if it helped. :) Thanks

    – user3445140
    May 29 '17 at 7:29
















33















GIT: I'm trying to push a file to a repo of a friend but errors on public key.



git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.


Where and how do we define public / private keys?



git remote -v returns:



origin  git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)


any help is appreciated.










share|improve this question


















  • 2





    possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

    – AD7six
    Oct 29 '13 at 14:23











  • Hi @wyguf, Please accept my answer if it helped. :) Thanks

    – user3445140
    May 29 '17 at 7:29














33












33








33


10






GIT: I'm trying to push a file to a repo of a friend but errors on public key.



git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.


Where and how do we define public / private keys?



git remote -v returns:



origin  git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)


any help is appreciated.










share|improve this question














GIT: I'm trying to push a file to a repo of a friend but errors on public key.



git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.


Where and how do we define public / private keys?



git remote -v returns:



origin  git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)


any help is appreciated.







git permissions key public denied






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 29 '13 at 14:15









Wyguf SeakWyguf Seak

198138




198138








  • 2





    possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

    – AD7six
    Oct 29 '13 at 14:23











  • Hi @wyguf, Please accept my answer if it helped. :) Thanks

    – user3445140
    May 29 '17 at 7:29














  • 2





    possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

    – AD7six
    Oct 29 '13 at 14:23











  • Hi @wyguf, Please accept my answer if it helped. :) Thanks

    – user3445140
    May 29 '17 at 7:29








2




2





possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

– AD7six
Oct 29 '13 at 14:23





possible duplicate of github: newbie problems -> Permission denied (publickey). fatal: The remote end hung up unexpectedly

– AD7six
Oct 29 '13 at 14:23













Hi @wyguf, Please accept my answer if it helped. :) Thanks

– user3445140
May 29 '17 at 7:29





Hi @wyguf, Please accept my answer if it helped. :) Thanks

– user3445140
May 29 '17 at 7:29












12 Answers
12






active

oldest

votes


















66














I was facing same problem, here is what I did that worked for me.



Use ssh instead of http. Remove origin if its http.



git remote rm origin


Add ssh url



git remote add origin git@github.com:<username>/<repo>.git


Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.



cd ~/.ssh
ssh-keygen


Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.



cat ~/.ssh/id_rsa.pub


Add this key to your github account. Next do



ssh -T git@github.com


You will get a welcome message in your console.



cd into to your project folder. git push -u origin master now works!






share|improve this answer





















  • 1





    I got the welcome message but git push -u origin master still doesn't work

    – Hack-R
    Nov 14 '16 at 16:56






  • 1





    Steps git remote rm and git remote add only was enough in my case.

    – Stephan Ahlf
    Mar 16 '17 at 19:35



















16














I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.



1. cat ~/.ssh/id_rsa.pub
2. copy the key, including the "ssh-rsa" but *excluding your computer name at the end*
3. Go to: https://github.com/settings/ssh
4. Add your SSH key





share|improve this answer


























  • Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

    – Argho Chatterjee
    Jul 4 '17 at 9:13



















9














This worked for me.



first of all, remove current remote :



git remote rm origin


second, add remote through HTTPS but git@xxx :



git remote add origin https://github.com/Sesamzaad/NET.git


then push has worked for me :



git push origin master





share|improve this answer


























  • did not work for me

    – Edi Bice
    Jul 5 '17 at 14:02






  • 1





    worked for me !

    – John Joe
    Oct 27 '17 at 17:14











  • Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

    – Daniel L. VanDenBosch
    Dec 11 '17 at 16:05











  • i use file credentials and git@ messes things up trying to use a public key.. ty for answer

    – Dan Bradbury
    Dec 1 '18 at 5:06



















5














None of the above solutions worked for me. For context, I'm running ubuntu, and I had already gone through the ssh-key setup documentation. The fix for me was to run ssh-add in the terminal. This fixed the issue.



Source: http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html






share|improve this answer































    3














    I am running Ubuntu 16.04



    Removing the remote origin using



    git remote rm origin


    setting the http url using



    git remote add origin https://github.com/<<Entire Path of the new Repo>>

    git push origin master


    Above steps successfully added code to repo.






    share|improve this answer































      2














      I fixed it by readding the key to my ssh-agent. For some reasons it was gone.






      share|improve this answer



















      • 2





        ssh-add -k ~/.ssh/id_rsa did it for me

        – Dbz
        Sep 19 '18 at 20:01



















      1














      You probably have to add your public key to github. https://help.github.com/articles/generating-ssh-keys



      Check this thread: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly






      share|improve this answer

































        1














        This worked for me. Simplest solution by far.



        If you are using GitHub for Windows and getting this error, the problem might be that you are trying to run the command in the wrong shell or mode. If you are trying to do git push origin master in the regular command prompt or PowerShell, this is the problem.



        You need to do it in a git shell. Simply open Github for Windows, right click, and select "Open Shell Here". It looks like a regular PowerShell window, but it's not, which makes it really confusing for newbies to git, like myself.



        I hope others find this useful.






        share|improve this answer































          0














          If you already have your public key added to the GITHUB server there are other solutions that you can try.



          In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.



          For more solutions visit this page
          https://github.com/gitlabhq/gitlabhq/issues/4730






          share|improve this answer

































            0














            In order to deploy to your friend's repo you need to add your public key to the repository's deploy keys.



            Go to the repository, go to deploy keys, and add the id_rsa.pub (or whatever yours is named) to "deploy keys".



            I believe adding the key to your own account only lets you write to repositories that your account created. If it was created by an organization you need to add the key to the repo's deploy keys.



            https://developer.github.com/v3/guides/managing-deploy-keys/






            share|improve this answer































              0














              I faced the same problem.Ask your friend to add you as a collaborator by going to his repo settings and adding a new collaborator.



              You will recieve an invite email ,accept it.Then you are good to go.
              Just make sure that you have added right remote.






              share|improve this answer































                0














                This error happened while using Ubuntu Bash on Windows.



                I switched to standard windows cmd prompt, and it worked no error.



                This is a workaround as it means you probably need to load the ssh private key in ubuntu environment if you want to use ubuntu.






                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19660744%2fgit-push-permission-denied-public-key%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  12 Answers
                  12






                  active

                  oldest

                  votes








                  12 Answers
                  12






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  66














                  I was facing same problem, here is what I did that worked for me.



                  Use ssh instead of http. Remove origin if its http.



                  git remote rm origin


                  Add ssh url



                  git remote add origin git@github.com:<username>/<repo>.git


                  Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.



                  cd ~/.ssh
                  ssh-keygen


                  Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.



                  cat ~/.ssh/id_rsa.pub


                  Add this key to your github account. Next do



                  ssh -T git@github.com


                  You will get a welcome message in your console.



                  cd into to your project folder. git push -u origin master now works!






                  share|improve this answer





















                  • 1





                    I got the welcome message but git push -u origin master still doesn't work

                    – Hack-R
                    Nov 14 '16 at 16:56






                  • 1





                    Steps git remote rm and git remote add only was enough in my case.

                    – Stephan Ahlf
                    Mar 16 '17 at 19:35
















                  66














                  I was facing same problem, here is what I did that worked for me.



                  Use ssh instead of http. Remove origin if its http.



                  git remote rm origin


                  Add ssh url



                  git remote add origin git@github.com:<username>/<repo>.git


                  Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.



                  cd ~/.ssh
                  ssh-keygen


                  Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.



                  cat ~/.ssh/id_rsa.pub


                  Add this key to your github account. Next do



                  ssh -T git@github.com


                  You will get a welcome message in your console.



                  cd into to your project folder. git push -u origin master now works!






                  share|improve this answer





















                  • 1





                    I got the welcome message but git push -u origin master still doesn't work

                    – Hack-R
                    Nov 14 '16 at 16:56






                  • 1





                    Steps git remote rm and git remote add only was enough in my case.

                    – Stephan Ahlf
                    Mar 16 '17 at 19:35














                  66












                  66








                  66







                  I was facing same problem, here is what I did that worked for me.



                  Use ssh instead of http. Remove origin if its http.



                  git remote rm origin


                  Add ssh url



                  git remote add origin git@github.com:<username>/<repo>.git


                  Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.



                  cd ~/.ssh
                  ssh-keygen


                  Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.



                  cat ~/.ssh/id_rsa.pub


                  Add this key to your github account. Next do



                  ssh -T git@github.com


                  You will get a welcome message in your console.



                  cd into to your project folder. git push -u origin master now works!






                  share|improve this answer















                  I was facing same problem, here is what I did that worked for me.



                  Use ssh instead of http. Remove origin if its http.



                  git remote rm origin


                  Add ssh url



                  git remote add origin git@github.com:<username>/<repo>.git


                  Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.



                  cd ~/.ssh
                  ssh-keygen


                  Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.



                  cat ~/.ssh/id_rsa.pub


                  Add this key to your github account. Next do



                  ssh -T git@github.com


                  You will get a welcome message in your console.



                  cd into to your project folder. git push -u origin master now works!







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Sep 23 '15 at 20:12









                  Eric Leschinski

                  87.7k38323275




                  87.7k38323275










                  answered Sep 2 '14 at 12:44









                  user3445140user3445140

                  851611




                  851611








                  • 1





                    I got the welcome message but git push -u origin master still doesn't work

                    – Hack-R
                    Nov 14 '16 at 16:56






                  • 1





                    Steps git remote rm and git remote add only was enough in my case.

                    – Stephan Ahlf
                    Mar 16 '17 at 19:35














                  • 1





                    I got the welcome message but git push -u origin master still doesn't work

                    – Hack-R
                    Nov 14 '16 at 16:56






                  • 1





                    Steps git remote rm and git remote add only was enough in my case.

                    – Stephan Ahlf
                    Mar 16 '17 at 19:35








                  1




                  1





                  I got the welcome message but git push -u origin master still doesn't work

                  – Hack-R
                  Nov 14 '16 at 16:56





                  I got the welcome message but git push -u origin master still doesn't work

                  – Hack-R
                  Nov 14 '16 at 16:56




                  1




                  1





                  Steps git remote rm and git remote add only was enough in my case.

                  – Stephan Ahlf
                  Mar 16 '17 at 19:35





                  Steps git remote rm and git remote add only was enough in my case.

                  – Stephan Ahlf
                  Mar 16 '17 at 19:35













                  16














                  I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.



                  1. cat ~/.ssh/id_rsa.pub
                  2. copy the key, including the "ssh-rsa" but *excluding your computer name at the end*
                  3. Go to: https://github.com/settings/ssh
                  4. Add your SSH key





                  share|improve this answer


























                  • Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                    – Argho Chatterjee
                    Jul 4 '17 at 9:13
















                  16














                  I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.



                  1. cat ~/.ssh/id_rsa.pub
                  2. copy the key, including the "ssh-rsa" but *excluding your computer name at the end*
                  3. Go to: https://github.com/settings/ssh
                  4. Add your SSH key





                  share|improve this answer


























                  • Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                    – Argho Chatterjee
                    Jul 4 '17 at 9:13














                  16












                  16








                  16







                  I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.



                  1. cat ~/.ssh/id_rsa.pub
                  2. copy the key, including the "ssh-rsa" but *excluding your computer name at the end*
                  3. Go to: https://github.com/settings/ssh
                  4. Add your SSH key





                  share|improve this answer















                  I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.



                  1. cat ~/.ssh/id_rsa.pub
                  2. copy the key, including the "ssh-rsa" but *excluding your computer name at the end*
                  3. Go to: https://github.com/settings/ssh
                  4. Add your SSH key






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 21 '15 at 12:13









                  eh1160

                  4181412




                  4181412










                  answered Sep 4 '14 at 13:37









                  steelsteel

                  6,01554271




                  6,01554271













                  • Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                    – Argho Chatterjee
                    Jul 4 '17 at 9:13



















                  • Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                    – Argho Chatterjee
                    Jul 4 '17 at 9:13

















                  Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                  – Argho Chatterjee
                  Jul 4 '17 at 9:13





                  Yes This One Works, I need to add the generated SSH key from My computer to GitHub as explained above in the comment. @user3445140's answer is not complete.

                  – Argho Chatterjee
                  Jul 4 '17 at 9:13











                  9














                  This worked for me.



                  first of all, remove current remote :



                  git remote rm origin


                  second, add remote through HTTPS but git@xxx :



                  git remote add origin https://github.com/Sesamzaad/NET.git


                  then push has worked for me :



                  git push origin master





                  share|improve this answer


























                  • did not work for me

                    – Edi Bice
                    Jul 5 '17 at 14:02






                  • 1





                    worked for me !

                    – John Joe
                    Oct 27 '17 at 17:14











                  • Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                    – Daniel L. VanDenBosch
                    Dec 11 '17 at 16:05











                  • i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                    – Dan Bradbury
                    Dec 1 '18 at 5:06
















                  9














                  This worked for me.



                  first of all, remove current remote :



                  git remote rm origin


                  second, add remote through HTTPS but git@xxx :



                  git remote add origin https://github.com/Sesamzaad/NET.git


                  then push has worked for me :



                  git push origin master





                  share|improve this answer


























                  • did not work for me

                    – Edi Bice
                    Jul 5 '17 at 14:02






                  • 1





                    worked for me !

                    – John Joe
                    Oct 27 '17 at 17:14











                  • Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                    – Daniel L. VanDenBosch
                    Dec 11 '17 at 16:05











                  • i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                    – Dan Bradbury
                    Dec 1 '18 at 5:06














                  9












                  9








                  9







                  This worked for me.



                  first of all, remove current remote :



                  git remote rm origin


                  second, add remote through HTTPS but git@xxx :



                  git remote add origin https://github.com/Sesamzaad/NET.git


                  then push has worked for me :



                  git push origin master





                  share|improve this answer















                  This worked for me.



                  first of all, remove current remote :



                  git remote rm origin


                  second, add remote through HTTPS but git@xxx :



                  git remote add origin https://github.com/Sesamzaad/NET.git


                  then push has worked for me :



                  git push origin master






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jul 5 '17 at 11:38









                  Mat M

                  1,176923




                  1,176923










                  answered Jul 5 '17 at 7:50









                  Cloud13thCloud13th

                  9111




                  9111













                  • did not work for me

                    – Edi Bice
                    Jul 5 '17 at 14:02






                  • 1





                    worked for me !

                    – John Joe
                    Oct 27 '17 at 17:14











                  • Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                    – Daniel L. VanDenBosch
                    Dec 11 '17 at 16:05











                  • i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                    – Dan Bradbury
                    Dec 1 '18 at 5:06



















                  • did not work for me

                    – Edi Bice
                    Jul 5 '17 at 14:02






                  • 1





                    worked for me !

                    – John Joe
                    Oct 27 '17 at 17:14











                  • Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                    – Daniel L. VanDenBosch
                    Dec 11 '17 at 16:05











                  • i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                    – Dan Bradbury
                    Dec 1 '18 at 5:06

















                  did not work for me

                  – Edi Bice
                  Jul 5 '17 at 14:02





                  did not work for me

                  – Edi Bice
                  Jul 5 '17 at 14:02




                  1




                  1





                  worked for me !

                  – John Joe
                  Oct 27 '17 at 17:14





                  worked for me !

                  – John Joe
                  Oct 27 '17 at 17:14













                  Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                  – Daniel L. VanDenBosch
                  Dec 11 '17 at 16:05





                  Hey thanks. this worked for me. I think this all started when we had a guy come in and "help" us create SSH keys

                  – Daniel L. VanDenBosch
                  Dec 11 '17 at 16:05













                  i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                  – Dan Bradbury
                  Dec 1 '18 at 5:06





                  i use file credentials and git@ messes things up trying to use a public key.. ty for answer

                  – Dan Bradbury
                  Dec 1 '18 at 5:06











                  5














                  None of the above solutions worked for me. For context, I'm running ubuntu, and I had already gone through the ssh-key setup documentation. The fix for me was to run ssh-add in the terminal. This fixed the issue.



                  Source: http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html






                  share|improve this answer




























                    5














                    None of the above solutions worked for me. For context, I'm running ubuntu, and I had already gone through the ssh-key setup documentation. The fix for me was to run ssh-add in the terminal. This fixed the issue.



                    Source: http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html






                    share|improve this answer


























                      5












                      5








                      5







                      None of the above solutions worked for me. For context, I'm running ubuntu, and I had already gone through the ssh-key setup documentation. The fix for me was to run ssh-add in the terminal. This fixed the issue.



                      Source: http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html






                      share|improve this answer













                      None of the above solutions worked for me. For context, I'm running ubuntu, and I had already gone through the ssh-key setup documentation. The fix for me was to run ssh-add in the terminal. This fixed the issue.



                      Source: http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 13 '16 at 20:13









                      vsahuvsahu

                      15016




                      15016























                          3














                          I am running Ubuntu 16.04



                          Removing the remote origin using



                          git remote rm origin


                          setting the http url using



                          git remote add origin https://github.com/<<Entire Path of the new Repo>>

                          git push origin master


                          Above steps successfully added code to repo.






                          share|improve this answer




























                            3














                            I am running Ubuntu 16.04



                            Removing the remote origin using



                            git remote rm origin


                            setting the http url using



                            git remote add origin https://github.com/<<Entire Path of the new Repo>>

                            git push origin master


                            Above steps successfully added code to repo.






                            share|improve this answer


























                              3












                              3








                              3







                              I am running Ubuntu 16.04



                              Removing the remote origin using



                              git remote rm origin


                              setting the http url using



                              git remote add origin https://github.com/<<Entire Path of the new Repo>>

                              git push origin master


                              Above steps successfully added code to repo.






                              share|improve this answer













                              I am running Ubuntu 16.04



                              Removing the remote origin using



                              git remote rm origin


                              setting the http url using



                              git remote add origin https://github.com/<<Entire Path of the new Repo>>

                              git push origin master


                              Above steps successfully added code to repo.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 6 '18 at 20:37









                              vignesh787vignesh787

                              514




                              514























                                  2














                                  I fixed it by readding the key to my ssh-agent. For some reasons it was gone.






                                  share|improve this answer



















                                  • 2





                                    ssh-add -k ~/.ssh/id_rsa did it for me

                                    – Dbz
                                    Sep 19 '18 at 20:01
















                                  2














                                  I fixed it by readding the key to my ssh-agent. For some reasons it was gone.






                                  share|improve this answer



















                                  • 2





                                    ssh-add -k ~/.ssh/id_rsa did it for me

                                    – Dbz
                                    Sep 19 '18 at 20:01














                                  2












                                  2








                                  2







                                  I fixed it by readding the key to my ssh-agent. For some reasons it was gone.






                                  share|improve this answer













                                  I fixed it by readding the key to my ssh-agent. For some reasons it was gone.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered May 2 '18 at 17:15









                                  Bennet G.Bennet G.

                                  132110




                                  132110








                                  • 2





                                    ssh-add -k ~/.ssh/id_rsa did it for me

                                    – Dbz
                                    Sep 19 '18 at 20:01














                                  • 2





                                    ssh-add -k ~/.ssh/id_rsa did it for me

                                    – Dbz
                                    Sep 19 '18 at 20:01








                                  2




                                  2





                                  ssh-add -k ~/.ssh/id_rsa did it for me

                                  – Dbz
                                  Sep 19 '18 at 20:01





                                  ssh-add -k ~/.ssh/id_rsa did it for me

                                  – Dbz
                                  Sep 19 '18 at 20:01











                                  1














                                  You probably have to add your public key to github. https://help.github.com/articles/generating-ssh-keys



                                  Check this thread: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly






                                  share|improve this answer






























                                    1














                                    You probably have to add your public key to github. https://help.github.com/articles/generating-ssh-keys



                                    Check this thread: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly






                                    share|improve this answer




























                                      1












                                      1








                                      1







                                      You probably have to add your public key to github. https://help.github.com/articles/generating-ssh-keys



                                      Check this thread: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly






                                      share|improve this answer















                                      You probably have to add your public key to github. https://help.github.com/articles/generating-ssh-keys



                                      Check this thread: GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 23 '17 at 11:54









                                      Community

                                      11




                                      11










                                      answered Jan 9 '14 at 22:41









                                      Walter BWalter B

                                      29936




                                      29936























                                          1














                                          This worked for me. Simplest solution by far.



                                          If you are using GitHub for Windows and getting this error, the problem might be that you are trying to run the command in the wrong shell or mode. If you are trying to do git push origin master in the regular command prompt or PowerShell, this is the problem.



                                          You need to do it in a git shell. Simply open Github for Windows, right click, and select "Open Shell Here". It looks like a regular PowerShell window, but it's not, which makes it really confusing for newbies to git, like myself.



                                          I hope others find this useful.






                                          share|improve this answer




























                                            1














                                            This worked for me. Simplest solution by far.



                                            If you are using GitHub for Windows and getting this error, the problem might be that you are trying to run the command in the wrong shell or mode. If you are trying to do git push origin master in the regular command prompt or PowerShell, this is the problem.



                                            You need to do it in a git shell. Simply open Github for Windows, right click, and select "Open Shell Here". It looks like a regular PowerShell window, but it's not, which makes it really confusing for newbies to git, like myself.



                                            I hope others find this useful.






                                            share|improve this answer


























                                              1












                                              1








                                              1







                                              This worked for me. Simplest solution by far.



                                              If you are using GitHub for Windows and getting this error, the problem might be that you are trying to run the command in the wrong shell or mode. If you are trying to do git push origin master in the regular command prompt or PowerShell, this is the problem.



                                              You need to do it in a git shell. Simply open Github for Windows, right click, and select "Open Shell Here". It looks like a regular PowerShell window, but it's not, which makes it really confusing for newbies to git, like myself.



                                              I hope others find this useful.






                                              share|improve this answer













                                              This worked for me. Simplest solution by far.



                                              If you are using GitHub for Windows and getting this error, the problem might be that you are trying to run the command in the wrong shell or mode. If you are trying to do git push origin master in the regular command prompt or PowerShell, this is the problem.



                                              You need to do it in a git shell. Simply open Github for Windows, right click, and select "Open Shell Here". It looks like a regular PowerShell window, but it's not, which makes it really confusing for newbies to git, like myself.



                                              I hope others find this useful.







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Apr 18 '15 at 12:45









                                              dberm22dberm22

                                              2,7662043




                                              2,7662043























                                                  0














                                                  If you already have your public key added to the GITHUB server there are other solutions that you can try.



                                                  In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.



                                                  For more solutions visit this page
                                                  https://github.com/gitlabhq/gitlabhq/issues/4730






                                                  share|improve this answer






























                                                    0














                                                    If you already have your public key added to the GITHUB server there are other solutions that you can try.



                                                    In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.



                                                    For more solutions visit this page
                                                    https://github.com/gitlabhq/gitlabhq/issues/4730






                                                    share|improve this answer




























                                                      0












                                                      0








                                                      0







                                                      If you already have your public key added to the GITHUB server there are other solutions that you can try.



                                                      In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.



                                                      For more solutions visit this page
                                                      https://github.com/gitlabhq/gitlabhq/issues/4730






                                                      share|improve this answer















                                                      If you already have your public key added to the GITHUB server there are other solutions that you can try.



                                                      In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.



                                                      For more solutions visit this page
                                                      https://github.com/gitlabhq/gitlabhq/issues/4730







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited Nov 5 '14 at 16:54

























                                                      answered Nov 5 '14 at 16:44









                                                      Mauricio Gracia GutierrezMauricio Gracia Gutierrez

                                                      5,55033659




                                                      5,55033659























                                                          0














                                                          In order to deploy to your friend's repo you need to add your public key to the repository's deploy keys.



                                                          Go to the repository, go to deploy keys, and add the id_rsa.pub (or whatever yours is named) to "deploy keys".



                                                          I believe adding the key to your own account only lets you write to repositories that your account created. If it was created by an organization you need to add the key to the repo's deploy keys.



                                                          https://developer.github.com/v3/guides/managing-deploy-keys/






                                                          share|improve this answer




























                                                            0














                                                            In order to deploy to your friend's repo you need to add your public key to the repository's deploy keys.



                                                            Go to the repository, go to deploy keys, and add the id_rsa.pub (or whatever yours is named) to "deploy keys".



                                                            I believe adding the key to your own account only lets you write to repositories that your account created. If it was created by an organization you need to add the key to the repo's deploy keys.



                                                            https://developer.github.com/v3/guides/managing-deploy-keys/






                                                            share|improve this answer


























                                                              0












                                                              0








                                                              0







                                                              In order to deploy to your friend's repo you need to add your public key to the repository's deploy keys.



                                                              Go to the repository, go to deploy keys, and add the id_rsa.pub (or whatever yours is named) to "deploy keys".



                                                              I believe adding the key to your own account only lets you write to repositories that your account created. If it was created by an organization you need to add the key to the repo's deploy keys.



                                                              https://developer.github.com/v3/guides/managing-deploy-keys/






                                                              share|improve this answer













                                                              In order to deploy to your friend's repo you need to add your public key to the repository's deploy keys.



                                                              Go to the repository, go to deploy keys, and add the id_rsa.pub (or whatever yours is named) to "deploy keys".



                                                              I believe adding the key to your own account only lets you write to repositories that your account created. If it was created by an organization you need to add the key to the repo's deploy keys.



                                                              https://developer.github.com/v3/guides/managing-deploy-keys/







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Oct 17 '17 at 23:08









                                                              the taothe tao

                                                              1101311




                                                              1101311























                                                                  0














                                                                  I faced the same problem.Ask your friend to add you as a collaborator by going to his repo settings and adding a new collaborator.



                                                                  You will recieve an invite email ,accept it.Then you are good to go.
                                                                  Just make sure that you have added right remote.






                                                                  share|improve this answer




























                                                                    0














                                                                    I faced the same problem.Ask your friend to add you as a collaborator by going to his repo settings and adding a new collaborator.



                                                                    You will recieve an invite email ,accept it.Then you are good to go.
                                                                    Just make sure that you have added right remote.






                                                                    share|improve this answer


























                                                                      0












                                                                      0








                                                                      0







                                                                      I faced the same problem.Ask your friend to add you as a collaborator by going to his repo settings and adding a new collaborator.



                                                                      You will recieve an invite email ,accept it.Then you are good to go.
                                                                      Just make sure that you have added right remote.






                                                                      share|improve this answer













                                                                      I faced the same problem.Ask your friend to add you as a collaborator by going to his repo settings and adding a new collaborator.



                                                                      You will recieve an invite email ,accept it.Then you are good to go.
                                                                      Just make sure that you have added right remote.







                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Jul 26 '18 at 7:23









                                                                      shivam bansalshivam bansal

                                                                      11




                                                                      11























                                                                          0














                                                                          This error happened while using Ubuntu Bash on Windows.



                                                                          I switched to standard windows cmd prompt, and it worked no error.



                                                                          This is a workaround as it means you probably need to load the ssh private key in ubuntu environment if you want to use ubuntu.






                                                                          share|improve this answer




























                                                                            0














                                                                            This error happened while using Ubuntu Bash on Windows.



                                                                            I switched to standard windows cmd prompt, and it worked no error.



                                                                            This is a workaround as it means you probably need to load the ssh private key in ubuntu environment if you want to use ubuntu.






                                                                            share|improve this answer


























                                                                              0












                                                                              0








                                                                              0







                                                                              This error happened while using Ubuntu Bash on Windows.



                                                                              I switched to standard windows cmd prompt, and it worked no error.



                                                                              This is a workaround as it means you probably need to load the ssh private key in ubuntu environment if you want to use ubuntu.






                                                                              share|improve this answer













                                                                              This error happened while using Ubuntu Bash on Windows.



                                                                              I switched to standard windows cmd prompt, and it worked no error.



                                                                              This is a workaround as it means you probably need to load the ssh private key in ubuntu environment if you want to use ubuntu.







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Oct 28 '18 at 17:30









                                                                              AndrewAndrew

                                                                              7,03144167




                                                                              7,03144167






























                                                                                  draft saved

                                                                                  draft discarded




















































                                                                                  Thanks for contributing an answer to Stack Overflow!


                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                  But avoid



                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                                                  To learn more, see our tips on writing great answers.




                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function () {
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19660744%2fgit-push-permission-denied-public-key%23new-answer', 'question_page');
                                                                                  }
                                                                                  );

                                                                                  Post as a guest















                                                                                  Required, but never shown





















































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown

































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown







                                                                                  Popular posts from this blog

                                                                                  404 Error Contact Form 7 ajax form submitting

                                                                                  How to know if a Active Directory user can login interactively

                                                                                  TypeError: fit_transform() missing 1 required positional argument: 'X'