Solution of permission denied (public key) in Git push

Time:2021-1-27

1 problem description

Solution of permission denied (public key) in Git push
The above error occurred when pushing. It said, please make sure that there are enough permissions and the warehouse exists, but the warehouse does not exist… This estimate is not, so it’s a problem of permissions. To be exact, it’s a problem of sshkey

2 regenerate SSH key

ssh-key -t rsa -b 4096 -C [email protected]

This is the method recommended by gitub to generate a new SSH key. Please do not use the default name. The first one will prompt you to enter a name. Please use a custom name

3 modify ~ /. SSH / config

Move public key and private key to ~ /. SSH

mv xxx xxx.pub ~/.ssh

Modify ~ /. SSH / config:

vim ~/.ssh/config

input

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/name

Where name is the user-defined key name in the previous step. It is the private key, not the public key at the end of. Pub

4 add public key to GitHub

In GitHub home page, click the top right corner to enter the settings
Solution of permission denied (public key) in Git push
Solution of permission denied (public key) in Git push
choice:
Solution of permission denied (public key) in Git push
Enter the name and public key and save
Solution of permission denied (public key) in Git push

5 push

Solution of permission denied (public key) in Git push
success!