GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Time:2019-10-16

1. Install git, register guthub account, and register code cloud account. This process will not be repeated.

2. Create a warehouse in GitHub and code cloud for testing

2.1. GitHub operation:

2.1.1 click the plus sign on the left side of the avatar, expand and selectNew repository(new warehouse)

GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

2.1.2 fill in the warehouse name, description, select the warehouse type (generally open, private charges are required), check readme, and then click generate warehouse.

GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

2.1.3 after clicking Create, the warehouse is generated as follows, with only one readme file.

GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

2.1.4 clone remote warehouse to local

Method 1: use HTTPS, which is like downloading things. You can use an HTTPS address.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

As shown in the figure above, it is the HTTPS address.
Create a new folder on your local computer
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
Enter the folder, right-click to selectGit Bush Here
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
Then it will automatically open the GIT command window.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
Enter the command git clone “HTTPS address” in the window, and then press enter
Note: please ensure that the remote warehouse type is public, otherwise you need to enter your GitHub account and password here
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
If the above interface appears, it means that the clone is successful. Go back to the directory of the local computer.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
You can see that there is more than one clone-test folder in the local folder, and the folder is exactly the same as the remote repository.

Method 2: SSH is used. SSH address is needed here.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

It can be found that the address of SSH is different from that of HTTPS.
We go back to the new folder on the local computer, delete the warehouse just cloned, and then repeat the above steps, just change the HTTPS address to SSH address.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

The authenticity of host ‘github.com (192.30.*.112)’ can’t be established.
The authenticity of the host ‘GitHub. Com (192.30. XXX. 112)’ cannot be determined.
Are you sure you want to continue connecting (yes/no)?
Are you sure you want to continue the link?

Enter yes enter
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Could not read from remote repository.
Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Please make sure that you have the right access and that the repository exists.

It doesn’t work. We need to configure SSH.
First, generate the SSH public key and key, and enter the following path. Generally, in the C disk user directory, the red part is your computer user name.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Right clickGIt Bush HereEnter commandsSSH keygen - t RSA - C "your email address" - F "customized key file name"
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Code parameter meaning:
-T specifies the key type, which is RSA by default and can be omitted.
-C set up the annotation text, and write it casually, such as email.
-F specifies the key file storage file name.
If you omit the – f parameter, running the above command will let you enter a file name to save the SSH key code just generated, such as:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Of course, you can also use the default file name (recommended) without entering the file name, and then two secret key files, i.e. id_rsa and id_rsa.pub, will be generated.
Then you will be prompted to enter the password twice(This password is the password you need to enter when you push the file, not the password of GitHub administrator.)Of course, you can press enter directly without entering the password. Then when push, it does not need to enter a password and submit it directly to Git server, such as:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Next, some prompts will be displayed, such as:
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f: f4:3b: CA: 85: d6:17: a1:7d: f0:68:9d: F0: A2: dbyour email address
When you see this display on git bash, it means that your SSH key has been created successfully. You only need to add it to the SSH key on git server.

Click on the avatar, expand and selectSetting
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Find the generated public key file, open it, copy all the contents and paste them into the key of GitHub.
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Now let’s try clone remote warehouse again
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

We found that it still can’t work. Then we test whether the next Kabbah can connect to GitHub, ` SSH – t [email protected]
`
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
Still not. Let’s check the specific information and find out what’s wrong.ssh -T -v [email protected]
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
You can see that it has been looking for these files.id_rsaandid_dsaThis is the default public key and key file name, and I renamed the name of the public key and key when I generated it, so it can’t be found, so we need to configure it to tell him which file to look for.
We execute under SSH foldertouch config, generate a config file, and then write it in the file
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key

Now try the link again
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
Link success
Let’s try clone remote warehouse again
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
GitHub, gitee create, connect, clone remote warehouse, generate and configure SSH public key
So far, it’s done.

The operation of the code cloud is basically the same as that of GitHub. Note that to generate another key and public key, you need to configure the config file.