I. Found the problem:
Permission denied (public key) when using the git clone command.
II. Solve the problem:
1. First, try to re-add the previously generated key, and add it several times, but it still does not work.
2. Use the command ssh -v [email protected]测试, the last few lines result in the following.
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/gr/.ssh/id_rsa
debug1: Trying private key: /home/gr/.ssh/id_dsa
debug1: Trying private key: /home/gr/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).
3. Analysis: Tried 3 private keys, but none of them worked, and finally it led to Permission denied.
4, check my key, ls ~/.ssh/ :
bajie bajie.pub known_hosts
5. I found that my id_rsa file I commanded as bajie, so it is not used at all. Also you can check the key list with the following command.
ssh-add -l
6. The key list of the above command is empty, so to add my key, use the command
gr@grpc:~/workspace/git/home$ ssh-add ~/.ssh/bajie
Enter passphrase for /home/gr/.ssh/bajie:
Identity added: /home/gr/.ssh/bajie (/home/gr/.ssh/bajie)
7. Check again, as follows, the addition was successful.
gr@grpc:~/workspace/git/home$ ssh-add -l
2048 63:c5:d8:6c:a0:0c:a8:9c:26:d8:f8:95:de:29:04:eb /home/gr/.ssh/bajie (RSA)
8. Use ssh -v [email protected]测试连接 again and you can see that the authentication is passed.
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/gr/.ssh/bajie
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.252.129]:22).
9. Finally, git clone project succeeded.