Git Crawling Pit - Building Remote Warehouse

Git Crawling Beginning - Establishing a Remote Warehouse: The core of building a remote warehouse is to establish ssh connection between local and git server. After initializing the local warehouse through git init, we need to paste the locally generated rsa secret key and paste it under github account to ensure consistency. A little carelessness, the tragedy of Permission denied It will happen again.

1. Establishing a remote git warehouse

Suppose we need to build MoConfig, a local code base, into a remote repository.
First, we create a MoConfig repository with the same name on the github website. (This is important, otherwise the "warehouse does not exist" error will be prompted when the push command is executed.) Submit the local code to the remote end.

Then, we need to convert the local existing code library into git warehouse init, establish a connection with remote add, and submit it to local add and commit.

>> git init
>> git remote add origin git@github.com:{$user_name}/MoConfig.git 
>> git add .
>> git commit -m "initialize the repository"
>> git push -u origin master

Normally, your local code base will have an extra. git / folder, as shown below.

2. Failure to establish connection with remote warehouse: Permission denied

Unfortunately, however, you have a Permission dened error during the creation of the warehouse, which indicates that your connection to the remote warehouse is not working.
The reason for this error is that the local machine has not established ssh connection trust with git server. The solution is to generate rsa key locally and copy it to github account. See STEP-1 and STEP-2 for solutions.

Warning: Permanently added the RSA host key for IP address '13.250.177.XXX' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
STEP-1: Generate a local rsa key, which is stored by default under / d/Users/LEE/.ssh/.
>> ssh-keygen -t rsa -C "{regester_email}"

The following is the output of the command. First, the key's storage address is set.

Generating public/private rsa key pair.
Enter file in which to save the key (/d/Users/LEE/.ssh/id_rsa):

If you own an rsa key, the system will ask if you overwrite the original key.

/d/Users/LEE/.ssh/id_rsa already exists.
Overwrite (y/n)? 

Set the password of the access key and return directly to indicate that it is not set.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Seeing the output below indicates that the final key generation is complete, a mysterious email from github will be sent to your registered mailbox.

Your identification has been saved in /d/Users/LEE/.ssh/id_rsa.
Your public key has been saved in /d/Users/LEE/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:mr+HhpTDqdoEERASioEZBoc/6jDu39ZVahPhgZwKKj0 xxx@163.com
The key's randomart image is:
+---[RSA 2048]----+
|@Oo   . o        |
|Oo o   + o       |
|ooo . . . o      |
|..E. .   o .     |
|...o . oS +      |
|+  .  *o =       |
|+.  .o+oo..      |
| o oo..oo .      |
|..ooo. .oo       |
+----[SHA256]-----+
STEP-2: Paste the local rsa key into the github account.

We found the id_rsa.pub file at the relevant address and pasted its contents under the github account.

// Part of id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA
BAQCrshsFvxn/Og5uwQ7HaoD6ph4
...
xxx@163.com

Finally, we enter the command to test whether the connection is successful.

>> ssh -T git@github.com

The following is the correct output to indicate the successful connection between the local computer and the git server.

Hi Gu-Youngfeng! You've successfully authenticated, 
but GitHub does not provide shell access.

Keywords: git ssh github Permission denied

Added by iFlex on Sat, 17 Aug 2019 17:02:56 +0300