You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Enter your GitHub account email as the Email Address
27
-
- Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below)
28
-
- You can use the privacy *@users.noreply.github.com* email address listed in the GitHub profile: *Settings > Email*
29
-
- Define a passphrase for the key and keep it in your password manager
31
+
1. Create a new GPG key:
30
32
31
-
```bash
32
-
gpg --armor --export ${my_email_address}| pbcopy
33
-
```
33
+
```bash
34
+
gpg --full-generate-key
35
+
```
34
36
35
-
- Public key is now in your clipboard - in your GitHub account add it to your profile via *Settings > SSH and GPG Keys> Add New GPG Key*
36
-
- Paste it in
37
+
1. Pick `RSA and RSA`, or `RSA (sign only)` (there is no elliptic curve cryptography (ECC) support at the time of writing)
38
+
1. `keysize` = `4096` bits (the minimum accepted for GitHub)
39
+
1. `Real name` = Your GitHub handle
40
+
1. `Email address` = Your GitHub account email [listed on your GitHub profile](https://github.com/settings/emails) (you can use the privacy *@users.noreply.github.com* email address): `Settings` ->`Emails` ->`Keep my email addresses private`)
37
41
38
-
```bash
39
-
git config --global user.email ${my_email_address}# same one used during key generation
40
-
git config --global user.name ${my_username}
41
-
git config --global commit.gpgsign true
42
-
sed -i '''/^export GPG_TTY/d'~/.zshrc
43
-
echoexport GPG_TTY=\$\(tty\)>>~/.zshrc
44
-
source~/.zshrc
45
-
PINENTRY_BIN=$(whereis -q pinentry-mac)
46
-
sed -i '''/^pinentry-program/d'~/.gnupg/gpg-agent.conf
> If you go for the private email option, consider enabling `Block command line pushes that expose my email`.
43
+
1. Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below)
44
+
1. Define a passphrase for the key
45
+
46
+
1. Check the key was made successfully:
47
+
48
+
```bash
49
+
gpg -k
50
+
```
50
51
51
-
The first time you commit you will be prompted to add the GPG key passphrase to the macOS Keychain. Thereafter signing will happen seamlessly without prompts.
52
+
1. Export the PGP PUBLIC KEY (to your clipboard):
52
53
53
-
Most of the published solutions for this don't work because *brew* seems to have moved the default folder for binaries, plus many guides contain obsolete settings for *gpg-agent*.
54
+
```bash
55
+
gpg --armor --export ${my_email_address}| pbcopy
56
+
```
57
+
58
+
1. [Add the public key to your GitHub account](https://github.com/settings/gpg/new) (`Settings` ->`SSH and GPG keys` ->`New GPG key`)
59
+
60
+
> Note the `Key ID` as you'll need this in the next step.
61
+
62
+
1. Set your local git config to use GPG signing:
63
+
64
+
```bash
65
+
git config --global user.email ${my_email_address} # same one used during key generation
66
+
git config --global user.name ${my_username}
67
+
git config --global user.signingkey = ${key_id}
68
+
git config --global commit.gpgsign true
69
+
git config --global tag.gpgsign true
70
+
```
71
+
72
+
> The first time you commit you will be prompted to add the GPG key passphrase to the macOS Keychain. Thereafter signing will happen seamlessly without prompts.
73
+
>
74
+
> Most of the published solutions for this don't work because *brew* seems to have moved the default folder for binaries, plus many guides contain obsolete settings for*gpg-agent*.
54
75
55
76
### Windows
56
77
57
-
- Install [Git for Windows](https://git-scm.com/download/win), which includes Bash and GnuPG
58
-
- Right-click on the Desktop > *Git Bash Here*
78
+
1. Install [Git for Windows](https://git-scm.com/download/win) (which includes Bash and GnuPG)
79
+
1. Right-click on the Desktop ->`Open Git Bash here`
80
+
1. Create a new GPG key:
59
81
60
-
```bash
61
-
gpg --full-generate-key
62
-
```
82
+
```bash
83
+
gpg --full-generate-key
84
+
```
63
85
64
-
- Pick *RSA and RSA*, or *RSA (sign only)* - there is no elliptic curve cryptography (ECC) support at the time of writing
65
-
- Set key size to 4096 bit, the minimum accepted for GitHub
66
-
- Enter your GitHub account name as the Real Name
67
-
- Enter your GitHub account email as the Email Address
68
-
- Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below)
69
-
- You can use the privacy *@users.noreply.github.com* email address listed in the GitHub profile: *Settings > Email*
70
-
- Define a passphrase for the key and keep it in your password manager
86
+
1. Pick `RSA and RSA`, or `RSA (sign only)` (there is no elliptic curve cryptography (ECC) support at the time of writing)
87
+
1. `keysize` = `4096` bits (the minimum accepted for GitHub)
88
+
1. `Real name` = Your GitHub handle
89
+
1. `Email address` = Your GitHub account email [listed on your GitHub profile](https://github.com/settings/emails) (you can use the privacy *@users.noreply.github.com* email address): `Settings` ->`Emails` ->`Keep my email addresses private`)
71
90
72
-
```bash
73
-
gpg --armor --export ${my_email_address}| clip
74
-
```
91
+
> If you go for the private email option, consider enabling `Block command line pushes that expose my email`.
92
+
1. Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below)
93
+
1. Define a passphrase for the key
75
94
76
-
- Public key is now in your clipboard - in your GitHub account add it to your profile via *Settings > SSH and GPG Keys> Add New GPG Key*
77
-
- Paste it in
95
+
1. Export the PGP PUBLIC KEY (to your clipboard):
78
96
79
-
```bash
80
-
git config --global user.email ${my_email_address}# same one used during key generation
81
-
git config --global user.name ${my_username}
82
-
git config --global commit.gpgsign true
83
-
```
97
+
```bash
98
+
gpg --armor --export ${my_email_address}| clip
99
+
```
100
+
101
+
1. [Add the public key to your GitHub account](https://github.com/settings/gpg/new) (`Settings` ->`SSH and GPG keys` ->`New GPG key`)
102
+
103
+
> Note the `Key ID` as you'll need this in the next step.
104
+
105
+
1. Set your local git config to use GPG signing:
106
+
107
+
```bash
108
+
git config --global user.email ${my_email_address} # same one used during key generation
109
+
git config --global user.name ${my_username}
110
+
git config --global user.signingkey = ${key_id}
111
+
git config --global commit.gpgsign true
112
+
git config --global tag.gpgsign true
113
+
```
114
+
115
+
1. Optional: Your new GPG key can be used within WSL, but not from Windows; to enable this:
0 commit comments