Skip to content

Instantly share code, notes, and snippets.

@exalted
Last active November 6, 2017 12:00
Show Gist options
  • Select an option

  • Save exalted/8253e67d6e740cbac73bfdc058ee0a3f to your computer and use it in GitHub Desktop.

Select an option

Save exalted/8253e67d6e740cbac73bfdc058ee0a3f to your computer and use it in GitHub Desktop.

Revisions

  1. exalted revised this gist Nov 6, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion How to generate a new PGP key.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,6 @@ The command above ask you a series of questions. We suggest you answer those as
    * Comment: Remind yourself for the purpose of this key
    * Passphrase: You can type anything you want here, but the idea is to make it long and complex enough. **DO NOT FORGET YOUR PHRASE!**
    * Done.
    ```

    At this point you must have a new pair of public-private keys. (They're binary files located in `~/.gnupg`, but it doesn't matter.)

  2. exalted revised this gist Nov 6, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions How to generate a new PGP key.md
    Original file line number Diff line number Diff line change
    @@ -43,10 +43,13 @@ Find the one (or possibly the only one) with the uid "Your full name (Remind you
    Find its "key id" which is a sequence of numbers and letters following sec rsa4096/.
    So, for instance, if your key looks like this:

    ```
    # sec rsa4096/6867755046FH7C4E 2017-09-18 [SC]
    # 1D45E70AB5FDF2844324B62E6867755046FH7C4E
    # uid Ali Servet Donmez (...) <[email protected]>
    # ssb rsa4096/999A5555X5DF6B6D 2017-09-18 [E]
    ```

    ... your "key id" in the example above would be 6867755046FH7C4E.

    Print your public key in ASCII armor format (of course you have to use your "key id" in the example below):
  3. exalted created this gist Nov 6, 2017.
    58 changes: 58 additions & 0 deletions How to generate a new PGP key.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    (Inspired by https://help.github.com/articles/generating-a-new-gpg-key/.)

    Install Homebrew (we will use Homebrew package manager to install `gpg` utility).

    :information_source: You could also install https://gpgtools.org instead, but I have no experience with it; so this guide will assume you have Homebrew installed.

    Install `gpg` using Homebrew:

    ```bash
    brew install gpg
    ```

    **Generate a new key (the most interesting part):**

    ```bash
    gpg --full-generate-key
    ```

    The command above ask you a series of questions. We suggest you answer those as follows:

    * Type of the key: RSA and RSA (default)
    * Length of the key: 4096
    * Expiration: Never
    * Name: Your full name
    * Email: [email protected]
    * Comment: Remind yourself for the purpose of this key
    * Passphrase: You can type anything you want here, but the idea is to make it long and complex enough. **DO NOT FORGET YOUR PHRASE!**
    * Done.
    ```
    At this point you must have a new pair of public-private keys. (They're binary files located in `~/.gnupg`, but it doesn't matter.)
    The next step is to go copy your public key and hand it over to someone and here's how you do it:
    List your keys:
    ```bash
    gpg --list-secret-keys --keyid-format LONG
    ```

    Find the one (or possibly the only one) with the uid "Your full name (Remind yourself for the purpose of this key) <[email protected]>"

    Find its "key id" which is a sequence of numbers and letters following sec rsa4096/.
    So, for instance, if your key looks like this:

    # sec rsa4096/6867755046FH7C4E 2017-09-18 [SC]
    # 1D45E70AB5FDF2844324B62E6867755046FH7C4E
    # uid Ali Servet Donmez (...) <[email protected]>
    # ssb rsa4096/999A5555X5DF6B6D 2017-09-18 [E]
    ... your "key id" in the example above would be 6867755046FH7C4E.

    Print your public key in ASCII armor format (of course you have to use your "key id" in the example below):

    ```bash
    gpg --armor --export 6867755046FH7C4E
    ```

    You could either copy & paste the terminal output, or pipe the output to `pbcopy` then paste it somewhere, or redirect the output to a file with `> foobar`.