"Solution" git add GitHub Remote Library to exempt account password verification

Source: Internet
Author: User
Tags ssh
Preface:

When I add a remote library to my local workspace, I use HTTPS to connect, which leads to cumbersome GitHub account password verification every time the local library is push to the remote library.

This article documents the process in which I resolved the problem, including the problems encountered and the solution. Solution Solutions

After you create a repository on GitHub, follow the prompts to connect the settings, first of all to determine the choice of SSH, the local terminal into the Gitrepository directory input commands

I entered the first line in the terminal after the command, nothing happened, right, Unix classic quotations: "No message is good news", and then enter the second line of the command, there is an error message:

➜  gitrepository git: (master) Git remote add Origin git@github.com/isleetender/gitrepository.git
➜  Gitrepository git: (master) Git pull Origin master
fatal: ' Git@github.com/isleetender/gitrepository.git ' does not appear to is a git repository
fatal:could not read from remote repository.

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

The error message says that the remote library that is being push does not seem to exist, or that the remote library has the correct access rights, and we can determine that the remote library is present, so there is only a problem with access rights.

OK, let's see if we have access to the target locally by command.

➜  gitrepository git: (master) ssh-t git@github.com
Permission denied (PublicKey).

The hint is clear: "No Permissions"

By looking at the data, knowing that the locally generated SSH key was not added to the remote GitHub, I opened the user directory of the. SSH directory (if there is no this directory, please continue with my operation below), found that there is no secret key generated: that is, no Id_rsa and id_rsa.pub two files:

➜  ~ CD. SSH
➜  . SSH ls
github_rsa     github_rsa.pub known_hosts

Next, generate the secret key from the command:
Ssh-keygen-t rsa-c "(Your email)"

And then always enter, know that the Martian text, the key will be generated success, back to the. SSH directory, found that there are Id_rsa and id_rsa.pub two files:

➜  ~ CD. SSH
➜  . SSH ls
github_rsa     github_rsa.pub id_rsa         id_rsa.pub     known_hosts

And then add the secret key to GitHub.

The title itself, the contents of the key is the. SSH directory in the contents of the Id_rsa.pub file, through the Cat id_rsa.pub command can be seen:

➜  . SSH cat id_rsa.pub
ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqdpazgqtfqoa3lhpxa6w5psqnh9rj9wq3+pr/ L2UTS6LKPYCXBNO6U8OZ+NMN7J5Q8L96NRRDST7CPSWLHHQ7+3M4WOMMBCBP ...

Then copy it and copy it to the key location.

Next, we'll check the ssh-t git@github.com to see if the permissions are sufficient:

Ok!

Let's push to try it:

Done. There is no need to enter the account password for the next push operation. Summary

The correct order to connect to the remote repository via SSH key is:
1. GitHub Create Remote Library
2. Create a secret key locally
3. Add the secret key to GitHub
4. Connect Remote Library
5. Submit the Operation

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.