Eclipse submits the project with the private key

Source: Internet
Author: User
Tags using git

The first time you install Git, you need to configure your username and mailbox, or Git will prompt you.

You need to run the command to configure your user name and mailbox:

$ git config--global user.name "superGG1990"

$ git config--global user.email "[email protected]"

Note: (Please enter your own name in quotation marks, and your own mailbox) This user name and mailbox are used to display your identity and contact information when git submits the code, not the GitHub user name and mailbox git uses SSH keys

GIT supports two transport protocols for HTTPS and git, and there are two types of protocols available when GitHub shares a link:

Git protocol link legend:

HTTPS protocol link legend:

GIT uses the HTTPS protocol, each pull, push will prompt to enter a password, use the GIT protocol, and then use the SSH key, so as not to lose the password every time the trouble users who use Git for the first time will probably need three steps to use the GIT protocol: first, generate key pair second, set the public key on the remote repository (in this case, GitHub) third, the GIT remote URL to modify the GIT protocol(after the first two steps have been set up, the subsequent use does not need to be set again, this step depends on the remote URL of the project later, if the protocol for other projects is HTTPS this step will be required)First, generate key pair

Most Git servers will choose to use the SSH public key for authorization. Each user in the system must provide a public key for authorization, and none will generate one. The process of generating the public key is similar on all operating systems. First, you need to confirm whether the machine already has a public key.

The SSH public key is stored by default in the ~/.ssh directory of the account's home directory. Go inside and see:

$ cd ~/. ssh$ lsauthorized_keys2  id_dsa       known_hosts config            id_dsa.pub

See if there are Id_rsa and id_rsa.pub(or a pair of files such as ID_DSA and id_dsa.pub), the file with the. Pub suffix is the public key, and the other file is the key.

Without these files, even the. SSH directory is not available and can be created with Ssh-keygen. The program is provided by the SSH package on the LINUX/MAC system and is included in the Msysgit package on Windows:

"[email protected]"public/Private inwhich to save the key (/home/you/.ssh/id_rsa):   

Press ENTER directly to the line. Then, you will be prompted to enter the password, as follows (it is recommended to lose one, a safe point, of course, do not lose, you should not be bored to fake you to modify your code):

Enter same passphrase again: [Type passphrase again]

After that, this is probably the case:

in/home/you/.ssh/01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected] 

At this end, your local key pair is generated.

Second, add the public key to your remote repository (GitHub)

1. View the public key you generated:

$ cat ~/.ssh/id_rsa.pub
Ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqc0x6l1zll4vhuvgb8ajh3ipptozmresuzgntvk434aj/v7kodj/mtyblwxfcr+ hao3fxritbqxix1nkhxphazsmcilq8vr3c8e7cjzn733f5al8ueyja+yzevy5ucveg+ Umt7phghkyajwacxv7sjyp7z6v79omceagdnxc26ibmdmgoluqjp6o6j2kadtrbdcds/qiu5thqdxj9lbxjk1fiq9tito/axbvjzed+gh/apkh /0GBO8VQLIYYMNFQQAHHEXDLTORN8N7C9LOA/UW3KM7QDXO6J0GFLBVQETE/IGQHMS5PMLN3 [email protected]

2. Log in to your GitHub account. Click on your avatar and then left column click ssh and GPG keys, click on New ssh key

3. Then you copy the above public key content and paste it into the "key" text field. The title field, the name of his own casually.

4. Click Add Key.

When you are done, verify that the key is working correctly:

$ ssh-T [email protected]attempts to ssh to GitHub

If, see:

Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access. 

Congratulations, your setup has been successful.

Third, modify the Git remote URL

Use the command git remote-v to view your current remote URL

$ git remote-vorigin https://Github.com/someaccount/someproject.git (FETCH) Origin https://  Github.com/someaccount/someproject.git (push)    

If this is the result then it means that the item is accessed using the HTTPS protocol (if the address is git at the beginning, it is the GIT protocol)

You can login to your github, just like the legend at the beginning of this article, you can see the corresponding URL of your SSH protocol above, similar to:

Copy this SSH link and then use the command git remote Set-url to adjust your URL.

Set-url origin [Email protected]:someaccount/someproject.git

Then you can use the command git remote-v to see if the URL has become an SSH address.

Then you can happily use git fetch, git pull, git push, and no more annoying passwords.

---------------------Eclipse to create a public key and use---------------------------------------

First, you need to generate the public and private keys with eclipse

Eclipse generates SSH2 key:Windows-perferences--general--network commection--ssh2--key management-- General RSA Key

Then register the generated SSH key on GitHub and log in to Github--settings--add to paste the SSH key generated by the appeal.

Note: This method is equivalent to the command line method, the company computer and its own laptop to paste the generated SSH key, you can add a lot of SSH key

See if the generated key is in the default system disk (C-drive), and some people will install it on other disks.

Then paste the generated public key onto GitHub:(This step cannot be omitted, be sure to check the generated public key with the command)

2. Commit the project using Git (using the secret key)

Eclipse submits the project with the private key

Related Article

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.