Unable to download/upgrade modules gpg fatal can't create directory

Hi,

So after fresh install on ubuntu 16.10 (php 5.6), i again see the warnings 'module…signed by invalid key’ .
to solve, i tried command: amportal a ma refreshsignatures which runs fine but these warnings are still there.

so, when i try to download/install new module i get this:
Error(s) downloading queues:
_File Integrity failed for /var/www/html/admin/modules/cache/queues-13.0.33.tgz.gpg - aborting (GPG Verify File check failed)

i tried following commands to resolve above error:
sudo -u asterisk gpg --refresh-keys --keyserver pool.sks-keyservers.net
sudo -u asterisk gpg --refresh-keys --keyserver hkp://keyserver.ubuntu.com:80
sudo -u asterisk gpg --refresh-keys --keyserver pgp.mit.edu
sudo -u asterisk gpg --refresh-keys --keyserver keyserver.pgp.com

result same everytime:
# sudo -u asterisk gpg --refresh-keys --keyserver hkp://keyserver.ubuntu.com:80
gpg: Fatal: can’t create directory ‘/root/.gnupg’: Permission denied

Kindly help!

Asterisk home directory is set to root

What do I need to do to fix this?

Here’s contents of asterisk.conf:
[directories]
astetcdir=/etc/asterisk
astmoddir=/usr/lib/asterisk/modules
astvarlibdir=/var/lib/asterisk
astagidir=/var/lib/asterisk/agi-bin
astspooldir=/var/spool/asterisk
astrundir=/var/run/asterisk
astlogdir=/var/log/asterisk
[options]
transmit_silence_during_record=yes
languageprefix=yes
execincludes=yes
[files]
astctlpermissions=775

Nobody got any idea here?

Log into the system at the console and use “vipw”. Check the settings for the “asterisk” user and make sure that the home directory is set correctly.

Gives the following output about asterisk:

asterisk:x:1000:1000::/home/asterisk:

You installed the system in Ubuntu, so you’re not using the Distro.

Something, somewhere in the Operating System permissions setup is hosed up.

The only way you’re going to solve this is to start reading up on using permissions, home directories, and environment inheritance to try to figure out which one thing out of literally hundreds of possible settings/options/commands is set incorrectly. It could be something as simple as your sudo is passing the root $HOME to ‘asterisk’ or it could be something in the real password database (which could be set up differently than in the distro).

This isn’t a FreePBX problem. It isn’t an Asterisk problem. This is a Unix shell problem and there are just too many places that this could be messed up.

i changed passwd of asterisk user (as i didnt know default) and ran gpg --refresh-keys commands with sudo and gpg error stands resolved. Thanks for all the help. However i get this error in asterisk console (and calls not working at all) now:

db.c:332 ast_db_put: Couldn’t execute statment: SQL logic error or missing database