We help IT Professionals succeed at work.
Get Started

GnuPG PHP website - encryption will not work from PHP

Daizzy-Mae asked
Last Modified: 2012-05-09
I am able to encrypt using PuTTY from the command line, but not from my web-page.

Here is my line of PHP code: system("/usr/bin/gpg --homedir /gnupg-files/.gnupg --encrypt -ao encryptedfile.txt -r 'Rhiannon <rhiannon@viva.org.uk>' 789.txt");

When I use PuTTY I type this in:
[timetogoveggie.com@shell1c40 /]$ gpg --homedir /gnupg-files/.gnupg --encrypt -a                      o encryptedfile.txt -r rhiannon@viva.org.uk 789.txt

Initially I thought it was a permissions problem but I seem to be logged in to PuTTY as the same user as I am on the website:

Website user:
echo system("id");

gives me
uid=186655(timetogoveggie.com) gid=100(users) groups=65533(nobody),65534(nogroup) uid=186655(timetogoveggie.com) gid=100(users) groups=65533(nobody),65534(nogroup)

PuTTY user:
[timetogoveggie.com@shell1c40 /]$ id -u

[timetogoveggie.com@shell1c40 /]$ whoami


We had GnuPG working nicely on the old server, then our hosting company got bought out by Aplus.net and we got moved to their servers... and now it will not work!

It simply will not create an encrypted file using GnuPG.

I am on Bash shell in Linux with fairly restricted permissions (eg. I am not allowed to use the chown command).

Do you think this could be a problem with my PHP in the line above?
Watch Question
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE