Git's SSH public key and a private key

Today's explore how to use Git operations, and to further implement the code downloaded to a local, I had not quite understand git generated public and private key role, I have been thinking, git which you put your public key git sent to the server, how he is judged, every time I finish changing the system, re-installed, how he is determined to change or complete system can still use git, and today we have to explain the simplest of SSh the clone method of operating the project:

1. Download the git client (only act on the upload & download)

2. No installation brain

3. Open the Git Bash, then generate a new secret key:

$ Ssh-keygen -t rsa -C "Your email address"
Now we emphasize that, if we did not write the address of a mailbox, then we git clone in the back of the code, he would be a mistake, an error that has prompted me to enter password, after the original generation .ssh inside the folder delete, again, you can

4.git clone

Before we clone, we need to git init, to initialize git repository

This time, when we put the machine to own public key available to the administrator, then we can from a remote server to download from the warehouse project

$ Git clone <repository address> "stored after Download"

This time can be a reminder, if the address is shaped like a git http: // xxx, this is using http way, our method is not suitable for ssh public key, if it is git @ gitxxx.git this case, it is of ssh. the way

 


Q & A:

1.git public and private keys stored where?

When I was 3, public and private keys generated by the above steps, in fact, every public key corresponding to a private key, and the key is equivalent to the relationship between the suo, a key opens a lock, 
a public key of a private match key, then the public and private keys generated address is determined, in: C: \ Users \ xxx \ .ssh which, if it is xxx.pub this is the public key, the private key is xxx,
this address is not It will change, so the server to match our private time, directly to the address on the line, so when we change the system, every time we put this back up next direct coverage of this place on the line.

 

2. The public and private key role in what is the use?

We generally to the server public key, they gave me the time to join in the authority's public key, and then when I download items from a remote warehouse, I git clone xxx at the time, 
the server I passed his tie given public key to match my private key, this time, if the match, then you can download the normal, if not match, then fail

 

.

 

 

.

Guess you like

Origin www.cnblogs.com/jianxian/p/12076209.html