· 8 years ago · Dec 19, 2017, 07:32 PM
1# Generating GPG Keys and adding it to Git.
2
3## Generating GPG Keys
4```
5gpg --gen-key
6```
7
8## List all GPG Keys
9```
10gpg --list-secret-keys --keyid-format LONG
11```
12
13## Using the key from previous command get the public key.
14> Public key can be added to GitHub for Verified commits.
15```
16gpg --armor --export secrent-key
17```
18
19## Configure Git to use GPG Keys for signing commits.
20```
21# Global use
22git config --global user.signingkey secret-key
23
24# Repository use
25git config user.signingkey secret-key
26```
27
28## Git commit signing (-S parameter)
29```
30git commit -S -m "Commit message"
31```
32
33## Using GPG Public Key to encrypt.
34> Some one's public GPG Key.
35```
36gpg --import gpg-public-key.gpg
37```
38
39## Encrypting a file using Public Key.
40```
41gpg --output new-encrypted-file.doc --encrypt --recipient recipient-email@example.com
42```
43
44## Decrypting an Encrypted file.
45```
46gpg --output new-decrypted-file.doc --decrypt encrypted-file.doc
47```