git push to remote repository is not authorized

Source: Internet
Author: User

In the process of using git, we may encounter problems with git push to GitHub remote repository but fail, prompting you to say that this push is not authorized.

Cause: The correct SSH public key pair is not matched. Either you did not generate the corresponding public key pair and deployed the public key to the corresponding project on GitHub, or you generated the key pair and deployed the public key on GitHub, your local directory did not configure the private key (or it was previously configured but expired)

Workaround:

(1) First, generate a public key pair:ssh-keygen-t rsa-c "youemail@example.com"-F ~/.ssh/id_rsa This command to create an SSH public key pair, " Youemail@example.com "for your own e-mail address," Id_rsa "is the public key name, can be modified. After the created public key pair is stored in the local directory C:\users\[username]\.ssh\ folder, you can view

(2) The public key is deployed on GitHub, and the Id_rsa.pub file generated in (1) is opened with a text editor and the contents are copied. In the corresponding GitHub project "setting" in the "SSH and GPG Keys" select "New SSH Key", the public key content paste up, create a new SSH key.

(3) Add the private key in the git bash command line. The command to view the list of private keys is:ssh-add-l, if the output above command appears could not open a connection to your authentication agent., then enter ssh-agent Bash, you can enter SSH bash. The command to add the private key:ssh-add ~/.ssh/id_rsa, then look at the list of private keys, if you have successfully added, you can normally use Git push to update the remote repository.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.