Problem description and troubleshooting

Git clone to a repo

git clone [email protected]:JiexingQi/picard.git
Cloning into 'picard'. [email protected]: Permission denied (publickey). fatal: Could notread from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Copy the code

Refer to blogs on the web, we can use this command to check first.

(picard) jxqi@han-server-01:~/text2sql$ ssh -T [email protected]
[email protected]: Permission denied (publickey).
Copy the code

Sure enough, even the normal Github was disconnected. An SSH publickey is missing. Consider whether SSH key information is correctly configured on the server.

You can run the following command to check whether an SSH configuration file exists:

ls -al ~/.ssh
Copy the code

The following information is displayed:

(picard) jxqi@han-server-01:~/text2sql$ ls -al ~/.ssh
total 16
drwxrwxr-x  2 jxqi jxqi 4096 Dec 20 17:02 .
drwxr-xr-x 17 jxqi jxqi 4096 Feb 11 16:43 ..
-rw-rw-r--  1 jxqi jxqi 2302 Jan 25 09:38 authorized_keys
-rw-r--r--  1 jxqi jxqi 1110 Jan  4 09:55 known_hosts
Copy the code

As you can see, the local SSH key is missing.

Problem solving

Once the problem is found, we simply need to configure the SSH key correctly. The configuration command is as follows:

ssh-keygen -t rsa -b 4096 -C "*********@qq.com"
Copy the code

All you need to do is fill in your github email address. This is my QQ mailbox.

The feedback results are as follows:

(picard) jxqi@han-server-01:~/text2sql$ ssh-keygen -t rsa -b 4096 -C "*******@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jxqi/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/jxqi/.ssh/id_rsa.
Your public key has been saved in /home/jxqi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:VmyKNm5jC98ewW/BJ0f+ydD5JcMD2zUsxlcGn4XNj3rYs ********@qq.com
The key's randomart image is: +---[RSA 4096]----+ | .+=| | . .o+| | + o. k++| | o = od *+o*| | + S + * O++| | o o o = +.*.| | . = . o .+.. | | = + o E . | | o.o | +----[SHA256]-----+Copy the code

Then check the SSH configuration file and github connection.

(picard) jxqi@han-server-01:~/text2sql$ ls -al ~/.ssh
total 24
drwxrwxr-x  2 jxqi jxqi 4096 Feb 13 14:06 .
drwxr-xr-x 17 jxqi jxqi 4096 Feb 11 16:43 ..
-rw-rw-r--  1 jxqi jxqi 2302 Jan 25 09:38 authorized_keys
-rw-------  1 jxqi jxqi 3243 Feb 13 14:06 id_rsa
-rw-r--r--  1 jxqi jxqi  743 Feb 13 14:06 id_rsa.pub
-rw-r--r--  1 jxqi jxqi 1110 Jan  4 09:55 known_hosts
(picard) jxqi@han-server-01:~/text2sql$ ssh -T [email protected]
Hi JiexingQi! You've successfully authenticated, but GitHub does not provide shell access.
Copy the code

It can be seen that the connection is normal, then git clone will be much smoother.

(picard) jxqi@han-server-01:~/text2sql$ git clone [email protected]:JiexingQi/picard.git
Cloning into 'picard'.Copy the code