Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk10 min

How to Use GPG to Encrypt and Sign Messages on a Linux VPS

A practical guide to using GPG on a Linux VPS: create or import keys, encrypt for recipients, sign files, decrypt and verify messages, and avoid common key-management failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use GnuPG (the gpg command) when a VPS must exchange messages that are confidential, authenticated, or both. Encrypt with the recipient’s public key, sign with your own secret key, and have the recipient decrypt with the matching secret key and verify with your public key. The commands below cover Debian- or Ubuntu-based servers, but package names and defaults can differ by distribution and installed GnuPG version.

For a message that needs both privacy and proof of origin, combine --sign and --encrypt. Keep the secret key, passphrase, and revocation certificate under strict control: a VPS is often unattended, so key exposure or loss can affect every automated exchange that depends on it.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What GPG protects—and what it does not

OpenPGP uses separate key roles. A recipient’s public key encrypts data so that only the corresponding secret key can decrypt it. Your secret key creates a digital signature; anyone holding your public key can verify that signature and detect changes to the signed data.

Operation Key used by sender Key needed by recipient Security property
Encrypt Recipient’s public key Recipient’s matching secret key Confidentiality
Sign Sender’s secret key Sender’s public key Integrity and authentication of key possession
Sign and encrypt Sender’s secret key plus recipient’s public key Recipient’s secret key plus sender’s public key Confidentiality, integrity and origin authentication

A valid signature does not prove that a person is trustworthy by itself; it proves that the data matches a signature made by the corresponding secret key. You still need to validate that the key belongs to the intended correspondent.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prepare GnuPG on the VPS

Install the distribution package

On Debian or Ubuntu, install the distribution’s GnuPG package with the normal package manager. Package splits and versions depend on the release, so use the package name supplied by that release rather than copying assumptions from another server.

sudo apt update
sudo apt install gnupg

Confirm which implementation and version are active:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
gpg --version

Read the local option and scripting details with man gpg. The installed manual is the authority for behavior that can vary between versions, especially in unattended jobs.

Use a dedicated account and protected home directory

Run cryptographic jobs under a dedicated Unix account rather than a general-purpose administrator account. GnuPG stores its keyrings, trust database and agent sockets below that account’s home directory, normally in ~/.gnupg. The directory must not be readable by other users.

  • Keep the account’s home and ~/.gnupg owned by that account.
  • Use restrictive permissions; the GnuPG directory is normally private to its owner.
  • Do not copy the account’s secret key material into web roots, application repositories or shared temporary directories.
  • Separate production and test keyrings so a test script cannot accidentally use a production identity.

Create or import the keys you need

Generate a new key pair interactively

For a new identity, start the interactive generator:

gpg --full-generate-key

Follow the prompts for key type, size or curve, expiration, identity and passphrase. Record the identity you choose, but use the complete fingerprint as the durable identifier in deployment records and scripts. A short key ID is not a reliable identifier because different keys can share one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Import an existing key

If the identity was created elsewhere, import the supplied public or secret key file:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
gpg --import keyfile.asc

Import a public key when you only need to encrypt to or verify a correspondent. Import a secret key only into the account that must decrypt or sign. After importing, inspect both keyrings:

gpg --list-keys
gpg --list-secret-keys

Record and verify fingerprints

Before encrypting, obtain the correspondent’s public-key certificate and verify its full fingerprint through an independent channel, such as a voice call or an already trusted administrative system. Do not treat a key downloaded from an unverified location as proof of identity. The certificate is required to encrypt correspondence and to verify signatures.

Perform the same check for your own public key before distributing it. Store the fingerprint alongside the account, environment and intended purpose. When a command names a key, prefer the full fingerprint in place of a short ID.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the revocation certificate

GnuPG creates a revocation certificate for a generated key. The Debian documentation identifies the openpgp-revocs.d directory below the GnuPG home. Copy the certificate to controlled, encrypted backup storage that is separate from the live VPS. Do not publish it unless the key is compromised, lost or otherwise no longer trustworthy; publishing a revocation tells correspondents to stop using that key.

Encrypt a file for one or more recipients

Binary output for file-safe transport

Use the recipient’s verified full fingerprint with --recipient. This creates a compact binary OpenPGP file:

gpg --output message.txt.gpg --recipient RECIPIENT_FINGERPRINT --encrypt message.txt

The original message.txt remains unchanged. The recipient needs the matching secret key to recover it. You can specify more than one recipient by repeating --recipient; each listed recipient can then decrypt the same encrypted data with their own secret key.

ASCII armor for text-only channels

When the transport accepts only text—such as a ticket, mail body or configuration field—add --armor:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
gpg --armor --output message.txt.asc --recipient RECIPIENT_FINGERPRINT --encrypt message.txt

Armor wraps the binary OpenPGP data in printable text. It is larger than binary output, so use the ordinary .gpg form when the transfer mechanism safely accepts binary files.

Check the recipient key before sending

  • Confirm that the selected fingerprint is the recipient’s current, non-expired public key.
  • Check that the key has not been revoked.
  • Make sure the key’s intended identity and email address match the exchange you are about to perform.
  • For sensitive workflows, record the fingerprint and key-expiration date in the deployment or runbook.

Sign a message, or sign and encrypt it

Detached signature

A detached signature leaves the original file readable and creates a separate signature file. This is useful when recipients already need the original file in its native format.

gpg --local-user YOUR_SIGNING_FINGERPRINT --output message.txt.sig --detach-sign message.txt

Send both message.txt and message.txt.sig. The verifier needs your public key and both files; changing even one byte of the original causes verification to fail. If a text-only channel is required for the signature, add --armor and use a text extension such as .asc.

Combined signed-and-encrypted message

For confidentiality and origin authentication in one artifact, sign first and encrypt the result for the recipient:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
gpg --armor 
  --local-user YOUR_SIGNING_FINGERPRINT 
  --recipient RECIPIENT_FINGERPRINT 
  --output message.txt.asc 
  --sign --encrypt message.txt

Remove --armor and use a .gpg output name when binary transfer is available. The signing key is selected by --local-user; omitting it makes GnuPG use its configured default key, which can be unsafe on a multi-identity VPS.

Encryption and signing solve different problems

Encryption hides content from anyone who lacks an intended recipient’s secret key. Signing allows a recipient to detect alteration and verify possession of the signer’s secret key. Encrypting without signing does not authenticate the sender, while signing without encryption leaves the content readable to anyone who obtains it. Choose both operations when both properties matter.

Decrypt and verify on the receiving VPS

Decrypt a combined message

With the recipient’s secret key available in the receiving account’s keyring, decrypt the armored or binary message:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
gpg --output message.txt --decrypt message.txt.asc

When the encrypted data contains a signature, GnuPG reports signature verification while it decrypts. Treat successful decryption and successful signature verification as separate results: a message can be decryptable but have an invalid, unknown or untrusted signature.

Verify a detached signature

Place the signed file and its detached signature together, then run:

gpg --verify message.txt.sig message.txt

--verify checks the signature without producing a second copy of the signed content. Read the complete status, including the signer fingerprint, and compare that fingerprint with the value obtained through your independent verification channel. A line saying that a signature is good confirms mathematical validity; it does not by itself establish that the key belongs to the person or service you expected.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Operate GPG safely on an unattended VPS

Protect passphrases and agent access

Never place a secret-key passphrase in shell history, a source file, a process argument or a world-readable environment variable. For interactive administration, configure gpg-agent with a suitable pinentry method so the passphrase is entered through the agent rather than embedded in a command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Unattended jobs need a documented batch design and machine-readable status handling. Use GnuPG’s batch and status interfaces instead of scraping human-readable terminal messages. Decide where failures, missing keys, expiry and signature errors are recorded, and make the job stop rather than silently sending an unencrypted file.

Back up and test recovery

Back up the secret key and its revocation certificate through a controlled, encrypted channel. Keep the backup separate from the VPS and restrict who can restore it. Test restoration on an isolated machine before relying on the backup; a backup that has never been restored is not a proven recovery plan.

Monitor expiry and revocation

Check key expiration and revocation status before sending. Plan a key-rotation procedure that distributes the replacement public key, updates fingerprints in automation and retires the old key deliberately. If a secret key is compromised or permanently lost, publish its revocation certificate and distribute the revoked status to correspondents. Do not continue encrypting to a key that has been revoked or whose ownership can no longer be established.

Keep scripts deterministic

  • Use full fingerprints, not short key IDs.
  • Specify --local-user when a keyring contains more than one signing identity.
  • Use explicit input and output paths and verify that the output was created before transferring it.
  • Preserve the original file until decryption and signature checks have succeeded on the other side.
  • Keep binary and armored file extensions consistent so operators do not mistake one format for the other.

Choose the right GPG form for the message

Decision Use this when Trade-off
Recipient-key encryption Several people or systems need to receive the same message without sharing one password. Each recipient needs a verified public key, and each recipient protects a corresponding secret key.
Symmetric encryption The sender and recipient can exchange and protect one shared passphrase through a separate secure channel. Key distribution and rotation become a shared-secret problem; anyone with the passphrase can decrypt.
Binary output The transfer mechanism accepts arbitrary bytes, such as an SCP or object-storage upload. Compact, but unsuitable for systems that alter or reject binary data.
ASCII armor The message must travel through a text-only field or mail body. Readable by text systems, but larger than the equivalent binary file.
Detached signature The original file must remain directly usable and a separate integrity file is acceptable. Both files must stay together and be verified with the correct public key.
Combined signature and encryption The recipient needs one artifact that is private and authenticated. Recipients need both the decrypting secret key and the signer’s verified public key.
Interactive operation An administrator is present to approve key use through pinentry. Safer passphrase handling, but unsuitable for a job that must run without an operator.
Automation A scheduled or event-driven service must process messages unattended. Requires batch/status handling, strict permissions and explicit failure monitoring.

Troubleshoot common failures

GPG says it cannot find a public key

List the public keyring with gpg --list-keys. If the recipient key is absent, import the correct certificate and verify its fingerprint before retrying. If several similar identities exist, use the full fingerprint in --recipient rather than relying on a name or short ID.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decryption reports no secret key

The receiving account does not have the secret key that matches the encryption recipient, or GnuPG is using a different home directory. Run gpg --list-secret-keys as the same Unix account that performs decryption, then import the controlled secret-key backup if necessary. Never solve this by copying secret material into a shared account.

The signature is bad or unknown

For a detached signature, confirm that the signature file matches the exact original file and that neither was changed during transfer. Import the signer’s public key, then compare the reported full fingerprint with the independently verified fingerprint. A mathematically good signature from an unverified key is not sufficient for an identity decision.

The command hangs waiting for input

An interactive pinentry prompt may be waiting on a terminal that the service does not have. Configure the agent and pinentry method for interactive work, or redesign the job around documented batch and status interfaces. Do not add a passphrase directly to a command line to bypass the prompt.

Armor is rejected by the transport

Use the armored .asc form only where text is required. For file-transfer systems that accept binary data, generate the .gpg form instead. Conversely, do not paste binary output into a text-only field, because the transport can corrupt it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A key is expired or revoked

Stop the transfer and check the key’s current status. Obtain a replacement public key through an independently authenticated channel, update the full fingerprint in the job configuration and document the change. If your own key was compromised or lost, publish its revocation certificate rather than continuing to use it.

VPS deployment checklist

  • Install and record the GnuPG version on the target distribution.
  • Run GPG under a dedicated account with a private ~/.gnupg directory.
  • Generate or import only the keys that account actually needs.
  • Record and independently verify complete fingerprints.
  • Store the revocation certificate and an encrypted secret-key backup outside the VPS.
  • Use recipient public keys for encryption and your own secret key for signing.
  • Choose binary output or ASCII armor based on the transport, not convenience.
  • Use detached signatures when the original file must remain separate; combine --sign and --encrypt when one confidential, authenticated artifact is preferable.
  • On receipt, check decryption and signature status separately and compare the signer fingerprint.
  • Keep passphrases out of history, source code and process arguments.
  • Make automated jobs fail visibly on missing, expired, revoked or unverifiable keys.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.