Summary

This article covers configuring Commerce EzyPay module's required gpg support on Linux based web-servers. GPG is used to encrypt your daily billing file prior to transmitting it to the EzyPay servers.
Commerce EzyPay requires you setup gpg on the command line for the user that your web-server runs as. This is either apache on RedHat style distros or www-data on Debian flavours.

Setting up GPG

Ssh to your server and switch to the user that your web-server runs as.
Create a directory outside your document root to store the gpg keys (eg /var/gpg or similar).
Take note of this folder - in all instructions below replace /path/to/folder with the actual path you used.

Setup your key

gpg --gen-key --homedir=/path/to/folder

When prompted enter 1 for the key type, 2048 for the size (default), 0 for expiry, y to confirm.
Complete the user identity questions as appropriate. This will create the key in the nominated folder

Export your key

gpg --export --armour –output public.txt <your email address of your key> --homedir=/path/to/folder

This will create your key as public.txt - email this file to EzyPay so they can continue with your account setup.

Import the EzyPay key

EzyPay will provide their public key, copy it to your server; take note of the location - replace /path/to/it-helpdesk.txt in the command below with the appropriate path.

gpg --import /path/to/it-helpdesk.txt --homedir=/path/to/folder

Sign the EzyPay key

gpg --sign-key ithelpdesk@ezypay.com.au --homedir=/path/to/folder

select y to sign the key

Trust the EzyPay key

gpg --edit-key ithelpdesk@ezypay.com.au --homedir=/path/to/folder

When prompted type 5 (trust ultimately) and y. Then enter quit command to leave edit mode.

File Permissions

Unless you want a slew of warnings regarding unsafe key storage, chown the path to your pgp folder so the group and the owner is the user the webserver runs as (eg apache or www-data). Then chmod the folder and subsequent files to 700.

# Example for Debian based distros
chown -R www-data:www-data /path/to/folder
chmod -R 700 /path/to/folder

Configuring Drupal

Now return to your Drupal site and enter the path to the folder (eg /var/pgp) under the Admin->Store->Configuration->Commerce EzyPay settings.