Git notify permission denies when pushing
# Git notify permission denies when pushing
When wer are using git push
, and got:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
1
2
2
There are two causes reasones:
- Haven't set up git
- Haven't set up SSH connection
# Setting up Git
# Method One:
Using git config
to config Git
$ git config --global user.name "Username"
$ git config --global user.email email@example.com
1
2
2
These two commands are used for config user name and email information. --global
represents it is a global configuration.
# Method Two:
You can use editor to config Git
- If you want to config git globally,open
/etc/gitconfig
,and add:
[user]
name = Username
email = YourEmail
1
2
3
2
3
- If you only want to change one user's setting, just edit
~/.gitconfig
.
If you want to know more about git, please check Git Official Website (opens new window)。
# Setting up GitHub SSH connection
- You need to generate a SSH key. Open terminal and type:
$ ssh-keygen -t rsa -C "YourEmail"
1
You can use all settings as default.
- After that, you could get a SSH public key and private key。(Default under:
~/.ssh/
. Then,copy fileid_rsa.pub
that is under that folder. - Click GitHub avatar,click "Settings"
- On the side bar,click “SSH and GPG keys” -> "Add SSH key"
- Paste the public key file and save。
笔记
If it's still not working, or it's not working after reboot. Run ssh-add [private_key_file_path]
. If you got error Could not open a connection to your authentication agent.
, please check this article (opens new window).
Environment:
-/+:.
:++++. OS: 64bit Mac OS X 10.14.5 18F132
/+++/. Kernel: x86_64 Darwin 18.6.0
.:-::- .+/:-``.::- Uptime: 3d 16h 35m
.:/++++++/::::/++++++/:` Packages: 48
.:///////////////////////:` Shell: zsh 5.6.2
////////////////////////` Resolution: 2880x1800
-+++++++++++++++++++++++` DE: Aqua
/++++++++++++++++++++++/ WM: Quartz Compositor
/sssssssssssssssssssssss. WM Theme: Blue
:ssssssssssssssssssssssss- CPU: Intel Core i7-4770HQ @ 2.20GHz
osssssssssssssssssssssssso/` GPU: Intel Iris Pro
`syyyyyyyyyyyyyyyyyyyyyyyy+` RAM: 8462MiB / 16384MiB
`ossssssssssssssssssssss/
:ooooooooooooooooooo+.
`:+oo+/:-..-:/+o+/-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Updated: 2021/09/09, 11:40:27