How to make GPG keys available to PHP shell_exec

I am working on a script that should run a perl script through the command line (using shell_exec()). To set up the script, I needed to generate a GPG key on my end and import their public key into the GPG firewall.

The Perl script works fine when I run it as a ROOT user, but when I run it through PHP it gives this error message:

"An error occurred while trying to sign the request"

I assume this means that the GPG keys that I installed in my root user are not accessible to the user. PHP executes its shell commands under (i.e. apache).

How do I solve this?

I don’t know if I need to log in as apache and import the keys, or if there is a command to run as root so that they can be accessed by the apache user ... Any ideas would be great :)

+3
source share
2 answers

Correctly. Obviously, you don’t want some simple mortal user like “apache” to sign things as root!

So you want to configure GPG for apache user. This is usually painful, since the Apache user usually cannot get the shell.

/home/<apache-user>, (, ). GPG apache. , root, --homedir=/home/<apache-user> gpg.

+2

apache :

su apache -s /bin/ksh

GPG. , apache /var/www, :

chmod a+w /var/www

GPG .gnupg

+3

Source: https://habr.com/ru/post/1761642/


All Articles