Using PGP Command Line to create and manage PGP keys (2024)

Table of Contents

  • Generating Keyring Files
  • Generate A Key Pair
  • Export The Public Key
    • Display the keys
    • Export the key
    • Export The Private Key or Keypair
  • Import a PGP Key
  • Deleting Keys from your Keyring
  • Check Keyring Location or Backup Keyrings
  • PGP Command Line and FIPS Mode

PGP uses Keys and Keyrings. Individual Keys, which are the unique identities to each PGP user are created and can be used for encryption and decryption.
These keys are then stored in Keyrings. Keyrings are basically files that contain the individual keys.

PGP Command Line uses the Keyrings and Keys paradigm, so the first step to get started with PGP Command Line is to create a Keyring.

pgp --create-keyrings

This will create a pubring.pkr (public keyring) and secring.skr (private keyring) file in the default keyring location.

For Windows this is in the Documents>PGP folder. This article will use [ ] to identify information that you will need to enter that is specific to your individual keys.

Pubring.pkr indicates a keyring that contains only public keys.

Secring.skr indicates a keyring that contains private keys. TIP: Make sure you do not share this keyring file with anyone for best security.

To create a key pair using PGP Command Line follow these steps:

  1. Open a command shell or DOS prompt.
  2. On the command line, enter:

    pgp --gen-key [user ID] --key-type [key type] --bits [bits #] --passphrase [passphrase]

    NOTE: Any information that contains spaces must be contained inside quotation marks. See the example below step 3.
  3. Press "Enter" when the command is complete.

    Example: The following example will show you how to create a 2048 Bit RSA key for Joe User, an employee of ACME Corp, with the passphrase "my passphrase".

    1. Open a command prompt and enter the following:

      pgp --gen-key "Joe User" --key-type RSA --bits 2048 --passphrase "my passphrase"

    2. Press "Enter"
  4. PGP Command line will now generate your keypair. You should see your Key ID (i.e. 0X12345678), and a message that the key was successfully generated.
  5. To display your new keypair enter the following command:

    pgp --list-keys


This will display all the keys that are found on your keyring.

Tip: Short version of listing a key is "pgp -l"

After the key pair is generated and identified, it is important to export the public portion (public key) of the key pair so others can import your public key and encrypt to you.

NOTE: Once you have exported your public key to a file, it is easy to distribute. You can attach it to an email, paste the public key block text into the body of an email message (open with Notepad), or copy to a CD, for example.
To export your public key you will need to have information about the key in order to identify it, which will be referred to in this document as (input). You can use the key ID (i.e. 0x12345678), user ID (i.e. "Joe User"), or a portion of the user ID, (i.e. Joe).

Display the keys

To display the keys on your keyrings, open a command prompt and type the following:

pgp --list-keys

Press Enter and the keys will be displayed. Make note of the key's username or number ID that you wish to export.

Export the key

To export the key, do the following:

  1. Open a command prompt.
  2. From the command prompt, enter:

    pgp --export (input)

    NOTE: Remember that any information that contains spaces must be contained inside quotes.
  3. Press "Enter" when the command is complete.

PGP Command Line responds by exporting keys as ASCII armor (.asc) files into the directory currently active on the command line.

Example 1 The following example will show you how to export your public key using your key ID.

  1. From the command prompt, enter:

    pgp --export 0x12345678

  2. Press "Enter".

Example 2 The following example will show you how to export your key using your user ID.

From the command prompt, enter:

pgp --export "Joe User"

Export The Private Key or Keypair

After the key pair is generated and identified, it is also highly recommended to export your keypair so you have a full backup of it and then store it in a safe location.

To export the keypair, use the following command if the Key ID for your key is "0x12345678":

pgp --export-key-pair 0x12345678 --output c:\my-own-keypair.asc

This will export the keypair to the c:\ drive, and will be called "my-own-keypair.asc", but you can use any path or filename that will work for you.

You may import a public key from an ASCII Armor file (.asc) or from a text file, the process is the same for both. The file containing the key(s) to be imported must be in the current directory. As with exporting a key, this will be referred to as (input) in the examples. Both public and private keys will be imported if they exist in the file. If a key being imported already exists in the local keyring, the keys are merged.

Import Key From File:

  1. Open a command prompt.
  2. From the command prompt, enter:

    pgp --import (input)

  3. Press "Enter" when the command is complete.

PGP Command Line responds as follows: Joe User.asc:import key {0:key imported as 0x12345678 Joe User}

Example 1 The following example will show you how to import a key from an ASCII Armor file (.asc).

  1. From the command prompt, enter:

    pgp --import "Joe User.asc"

  2. Press "Enter".

Example 2 The following example will show you how to import a key from a text file containing the PGP key block.

From the command prompt, enter:

pgp --import "PGP Joe.txt"

Press "Enter".

All of the above commands are how to create, and import keys to your keyring. There are other commands are more destructive, such as the ability to remove keys from your keyring.

For example, if you have a key in your keyring that is no longer a valid key, you can remove it so that you do not ever encrypt to that key again.

You want to be careful about deleting keys from your keyring, but it is useful to be able to do in case some keys are no longer valid.

If the Key ID for a key you wish to remove is "0x1234ABCD", then to remove the key from your keyring, you use the following command:

pgp --remove 0x1234ABCD

This will remove the public key from your keyring.

If you have a keypair that you no longer would like to use, you can issue the following command:

pgp --remove-key-pair 0x1234ABCD --force

CAUTION: It is a good idea to export your keypair first! Once you delete your keypair, you will no longer have it. Export the keypair first, and then you can delete it.

These are all the basic commands for using PGP Command Line to get started, but there are so many more commands available to use that offer a plethora of functionality to meet all your encryption/decryption needs. For more information on these additional commands and operations, see the following article:

158454 - Using PGP Command Line

PGP Command Line also has some very powerful functionality when combined with the Symantec Encryption Management Server, or PGP Server. When used in this way, you can store all your keys on the centralized PGP server, and then none of your keys need to be held locally. This is useful for scenarios where you may have multiple servers with PGP Command Line installed, and you want to have access to all the same keys. The PGP server can be the central repository to securely store your keys, which means better security for where the PGP Command Lice application is stored!

For more information on this functionality, see the following article:

159237 - Using PGP Command Line with Symantec Encryption Management Server (PGP Server)

The PGP Command Line uses keyring files to store each individual key. There are two keyring files:
pubring.pkr and secring.skr.

The pubring.pkr file contains only public keys. The secring.skr keyring file will contain private keys, or keypairs.

Both of these keyring files together will house all your keys. In order to see the location of your keyring run the following command:

pgp --version -v

This will display the location of your keyring files. This is handy to know as you can simply copy these files for backup.

Example:

Public Keyring: c:\Users\user1\Documents\PGP\pubring.pkr
Private Keyring: c:\Users\user1\Documents\PGP\secring.pkr

To make a backup of these files, simply copy them to another location.

To use PGP Command Line in FIPS mode, see the following article:

267847 - Enable FIPS mode with PGP Command Line Permanently

Using PGP Command Line to create and manage PGP keys (2024)

FAQs

How to generate PGP key command line? ›

Generate A Key Pair
  1. Open a command shell or DOS prompt.
  2. On the command line, enter: pgp --gen-key [user ID] --key-type [key type] --bits [bits #] --passphrase [passphrase] ...
  3. Press "Enter" when the command is complete. ...
  4. PGP Command line will now generate your keypair. ...
  5. To display your new keypair enter the following command:
Jan 31, 2024

How to use PGP encryption command line? ›

Encrypt the File
  1. Open a command prompt.
  2. From the command prompt, enter: pgp --encrypt (input) --recipient (user)
  3. Press Enter.
Jun 13, 2024

How to use PGP step by step? ›

Basic steps for using PGP
  1. Install PGP on your computer.
  2. Create a private and public key pair. Before you can begin using PGP, you need to generate a key pair. ...
  3. Exchange public keys with others. ...
  4. Validate public keys. ...
  5. Encrypt and sign your email and files. ...
  6. Decrypt and verify your email and files. ...
  7. Wipe files.

How are PGP keys generated? ›

First, PGP generates a random session key using one of two (main) algorithms. This key is a huge number that cannot be guessed, and is only used once. Next, this session key is encrypted. This is done using the public key of the intended recipient of the message.

What is the command to generate your GPG keys? ›

Generating a new keypair. The command-line option --gen-key is used to create a new primary keypair. alice% gpg --gen-key gpg (GnuPG) 0.9.

How to generate PGP private key from public key? ›

How to Generate a Public-Private Key Pair
  1. Generate a new keypair: gpg --full-generate-key --openpgp. ...
  2. Export the keypair to a file (use the same email address that you used for generating the key pair): ...
  3. Download the GoodData public PGP key .
  4. Import the GoodData public key to your keystore:

What are the four types of keys used by PGP? ›

PGP makes use of four types of keys: one-time session symmetric keys, public keys, private keys, and passphrase-based symmetric keys. Three separate requirements can be identified with respect to these keys: 1. a means of generating unpredictable session keys is needed.

Where is the PGP key stored? ›

PGP stores the keys in two files on your hard disk; one for public keys and one for private keys. These files are called keyrings. As you use PGP, you will typically add the public keys of your recipients to your public keyring. Your private keys are stored on your private keyring.

How to install PGP command line on windows? ›

Installing PGP Command Line on Windows
  1. Close all Windows applications.
  2. Download the installer application, PGPCommandLine105Win. zip, to a known location on your system.
  3. Unzip the file PGPCommandLine105Win. zip. ...
  4. Double click on PGPCommandLine105Win. ...
  5. Follow the on-screen instructions.
  6. If prompted, restart your machine.
Dec 12, 2023

How to create a PGP encrypted file? ›

How to encrypt files with Open PGP:
  1. Get your trading partner's public key to encrypt the file.
  2. Import your trading partner's public key into a Key Vault.
  3. Use your file transfer tool to create a Project to encrypt the file. ...
  4. Confirm that the project was set up correctly before executing.

How do I send a PGP key? ›

Sharing Your Public Key
  1. Open the Compose Window.
  2. From the Enigmail menu, select Attach Public Key..., then in the next panel, select the key you wish to attach to the message.
  3. Send the message with your key, but also remember to ask the recipient for their public key.
Jan 14, 2021

How the key management is done in PGP? ›

The PGP keys are stored in the system database. A key is a pair that comprises of private and public portions. In PGP, the private portion of the key is the Secret key and the public portion of the key is the Public key. Note: You can share a public key, but never share a private or secret key.

How do I open a PGP file with a key? ›

Decrypt a PGP Zip file
  1. Right click the file to be decrypted.
  2. Point to PGP Zip, and then click Decrypt & Verify.
  3. Enter the passphrase of your key and click OK.
  4. The decrypted file will then be saved in the same location as the encrypted file.
Aug 1, 2024

Can Putty generate PGP keys? ›

3. There are many key generators in the market like PUTTY, GP4win etc. and either of them can be used to create keys for SFTP, PGP, FTPS etc.

How to generate SSH key command line? ›

For Windows 10 & 11
  1. Press the Windows key or open up the Start Menu. Type “cmd”.
  2. Under “Best Match”, click “Command Prompt”.
  3. In the command prompt, use the ssh-keygen command: ...
  4. The system will now generate the key pair and display the key fingerprint and a randomart image. ...
  5. Open your file explorer.

How do I extract a PGP key? ›

Open PGP Desktop. Click "PGP Keys". Right-click the key to export, then select Copy Public Key. Also paste the key block of the public key to a text file as an additional backup.

Top Articles
Does a hedge fund need to register with any regulator?
A Complete Guide on Accrued Expenses
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 6488

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.