Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7730099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:08:16+00:00 2026-06-01T06:08:16+00:00

i am struggling with a gpg problem for a few days and cant figure

  • 0

i am struggling with a gpg problem for a few days and cant figure out a solution by my own. i would be glad if you could help me out with the following issue:

i need to decrypt a gpg file in php. for that, i am using the following command:

cat passphrase.txt | /usr/local/bin/gpg --decrypt --passphrase-fd 0 stammdaten.txt.gpg>stammdaten.txt

the passphrase.txt contains the password for decryption
stammdaten.txt.gpg is the encrypted file
the decrypted data will be written in stammdaten.txt

when i run this command in php:


shell_exec=("cat passphrase.txt | /usr/local/bin/gpg --decrypt --passphrase-fd 0 stammdaten.txt.gpg>stammdaten.txt")


i get a zero-byte output file (stammdaten.txt) with owner=ftpadmin and group=psacln

but when i execute the same command via ssh terminal (as root), the data will be decrypted and written correctly with file owner=root and group=root.

i think, that this is a permission problem. how can i use that command in php correctly? i also tried to chown and chgrp with the ftprightson the decrypted file, but nothing seems to help.

every answer is highly appreciated. thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:08:17+00:00Added an answer on June 1, 2026 at 6:08 am

    finally i got it to work:

    first of all, i changed the gpg command for decryption with echoing the passphrase into stdin:

    $passphrase = utf8_decode('mypassphrase');
    $encrypted = 'fullsystempathtogpgfile.gpg';
    
    "echo '$passphrase' | /usr/local/bin/gpg -v -v --batch --passphrase-fd 0 --no-default-keyring $encrypted";
    

    before executing with shell_exec i needed to change the homedir of gpg:

    before it was set with:

    putenv("GNUPGHOME=/var/www/.gnupg");
    

    but obviously the php user (in my case “ftpadmin”, found out with “whoami”) has no permission to access that directory, so i copied the .gpg folder into my new created php user folder: /home/ftpadmin (with 777 perms) and changed the GNUPGHOME:

    putenv("GNUPGHOME=/home/ftpadmin/.gnupg");
    

    now i am able to decrypt the gpg files with php. maybe you could find some help for your similar issue. thanks again for every answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Really struggling to figure this out. Just trying to take in data from php
Struggling with the following SQL problem. Assume a three dimensional table with entries (h,t,q)
Struggling with command line again, I have figure out that I can store the
Struggling with the following problem. I have an attribute that defines the name of
Really struggling to figure out extending the immutable Set with a class that will
In struggling with a solution to this problem I've run into another, related issue:
Been struggling with this simple selector problem a couple of hours now and must
Struggling a bit today. I have the following method that returns a list of
Struggling to get my head around these MD Arrays so hoping someone can help.
Struggling with this problem for an hour now and searched both stackoverflow and google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.