|
36 | 36 |
|
37 | 37 | 1. Pick `RSA and RSA`, or `RSA (sign only)` (there is no elliptic curve cryptography (ECC) support at the time of writing) |
38 | 38 | 1. `keysize` = `4096` bits (the minimum accepted for GitHub) |
| 39 | + 1. Select a key expiry time (personal choice) |
39 | 40 | 1. `Real name` = Your GitHub handle |
40 | 41 | 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`) |
41 | 42 |
|
42 | 43 | > If you go for the private email option, consider enabling `Block command line pushes that expose my email`. |
| 44 | + |
43 | 45 | 1. Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below) |
44 | 46 | 1. Define a passphrase for the key |
45 | 47 |
|
46 | | -1. Check the key was made successfully: |
47 | | - |
48 | | - ```bash |
49 | | - gpg -k |
50 | | - ``` |
51 | | - |
52 | 48 | 1. Export the PGP PUBLIC KEY (to your clipboard): |
53 | 49 |
|
54 | 50 | ```bash |
| 51 | + gpg -k # This should list the new key |
55 | 52 | gpg --armor --export ${my_email_address} | pbcopy |
56 | 53 | ``` |
57 | 54 |
|
|
76 | 73 | ### Windows |
77 | 74 |
|
78 | 75 | 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` |
| 76 | +1. Open `Git Bash` |
80 | 77 | 1. Create a new GPG key: |
81 | 78 |
|
82 | 79 | ```bash |
|
85 | 82 |
|
86 | 83 | 1. Pick `RSA and RSA`, or `RSA (sign only)` (there is no elliptic curve cryptography (ECC) support at the time of writing) |
87 | 84 | 1. `keysize` = `4096` bits (the minimum accepted for GitHub) |
| 85 | + 1. Select a key expiry time (personal choice) |
88 | 86 | 1. `Real name` = Your GitHub handle |
89 | 87 | 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`) |
90 | 88 |
|
91 | 89 | > If you go for the private email option, consider enabling `Block command line pushes that expose my email`. |
| 90 | + |
92 | 91 | 1. Avoid adding a comment (this *may* prevent git from auto-selecting a key - see Troubleshooting section below) |
93 | 92 | 1. Define a passphrase for the key |
94 | 93 |
|
95 | 94 | 1. Export the PGP PUBLIC KEY (to your clipboard): |
96 | 95 |
|
97 | 96 | ```bash |
| 97 | + gpg -k # This should list the new key |
98 | 98 | gpg --armor --export ${my_email_address} | clip |
99 | 99 | ``` |
100 | 100 |
|
|
112 | 112 | git config --global tag.gpgsign true |
113 | 113 | ``` |
114 | 114 |
|
115 | | -1. Optional: Your new GPG key can be used within WSL, but not from Windows; to enable this: |
| 115 | +1. Now your key is created, make it avalable within Windows: |
116 | 116 |
|
117 | 117 | 1. Export the key: |
118 | 118 |
|
|
124 | 124 |
|
125 | 125 | > **Ensure both `GnuPG` and `Kleopatra` are installed!** |
126 | 126 |
|
127 | | - 1. Open Kleopatra -> `Import` -> Select the `<GitHub handle>.pgp` file created in the first step. |
| 127 | + 1. Open Kleopatra -> `Import` -> Select the `<GitHub handle>.pgp` file created in the first step |
128 | 128 | 1. In `cmd`, set your local git config to use GPG signing: |
129 | 129 |
|
130 | 130 | ```bash |
| 131 | + gpg -k # This should list the new key |
131 | 132 | git config --global user.email ${my_email_address} # same one used during key generation |
132 | 133 | git config --global user.name ${my_username} |
133 | 134 | git config --global user.signingkey = ${key_id} |
134 | 135 | git config --global commit.gpgsign true |
135 | 136 | git config --global tag.gpgsign true |
136 | 137 | ``` |
137 | 138 |
|
| 139 | +1. And finally, make it avalable within WSL: |
| 140 | +
|
| 141 | + 1. Within Ubuntu: |
| 142 | +
|
| 143 | + ```bash |
| 144 | + sudo ln -s /mnt/c/Program\ Files\ \(x86\)/GnuPG/bin/gpg.exe /usr/local/bin/gpg |
| 145 | + sudo ln -s gpg /usr/local/bin/gpg2 |
| 146 | + ``` |
| 147 | +
|
| 148 | + 1. Close and reopen your Ubuntu terminal |
| 149 | +
|
| 150 | + 1. Test the key is visible: |
| 151 | +
|
| 152 | + ```bash |
| 153 | + gpg -k # This should list the new key |
| 154 | + ``` |
| 155 | +
|
138 | 156 | > When you commit, you'll now be prompted to enter the GPG key passphrase into a Pinentry window. |
139 | 157 |
|
140 | 158 | ## From Pipelines |
|
0 commit comments