# After Upgrade on new Server Private Key not valid

**URL:** <https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540>\
**Category:** Installation Issues\
**Created:** [May 26, 2023, 7:51am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540 "2023-05-26T07:51:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@Fabian](https://community.passbolt.com/u/Fabian)\
**Post date:** [May 26, 2023, 7:51am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/1 "2023-05-26T07:51:18Z")

</div>

**Checklist**  
 I have read intro post: [About the Installation Issues category](https://community.passbolt.com/t/about-the-installation-issues-category/12)  
 I have read the tutorials, help and searched for similar issues  
 I provide relevant information about my server (component names and versions, etc.)  
 I provide a copy of my logs and healthcheck  
 I describe the steps I have taken to trouble shoot the problem  
 I describe the steps on how to reproduce the issue

Hello,

we tried to upgrade Passbolt from version 2.4.1 to the latest version on a new server running Ubuntu 22.04.2.

We followed this guide: [Passbolt Help | Migrate an existing Passbolt CE to a new Ubuntu server](https://help.passbolt.com/hosting/upgrade/ce/migrate-existing-ce-to-ubuntu-server.html)

However we get an error when importing the old serverkey:

```auto
fabian@passbolt:~$ sudo su -s /bin/bash -c "gpg --home /var/lib/passbolt/.gnupg --import --verbose --pinentry-mode loopback /etc/passbolt/gpg/serverkey_private.asc" www-data
gpg: sec rsa2048/F47BC46B7421040D 2020-07-13 Fabian (nope) <fabian.schaefer@iris-sport.de>
gpg: key F47BC46B7421040D: "Fabian (nope) <fabian.schaefer@iris-sport.de>" not changed
gpg: key F47BC46B7421040D/F47BC46B7421040D: error sending to agent: Permission denied
gpg: error building skey array: Permission denied
gpg: error reading '/etc/passbolt/gpg/serverkey_private.asc': Permission denied
gpg: import from '/etc/passbolt/gpg/serverkey_private.asc' failed: Permission denied
gpg: Total number processed: 0
gpg: unchanged: 1
gpg: secret keys read: 1

```

The permissions are all as they should be according to the guide

Healthcheck:

```auto
GPG Configuration

 [PASS] PHP GPG Module is installed and loaded.
 [PASS] The environment variable GNUPGHOME is set to /var/lib/passbolt/.gnupg.
 [PASS] The directory /var/lib/passbolt/.gnupg containing the keyring is writable by the webserver user.
 [PASS] The server OpenPGP key is not the default one
 [PASS] The public key file is defined in /etc/passbolt/passbolt.php and readable.
 [PASS] The private key file is defined in /etc/passbolt/passbolt.php and readable.
 [PASS] The server key fingerprint matches the one defined in /etc/passbolt/passbolt.php.
 [FAIL] The server public key defined in the /etc/passbolt/passbolt.php (or environment variables) is not in the keyring
 [HELP] Import the private server key in the keyring of the webserver user.
 [HELP] you can try:
 [HELP] sudo su -s /bin/bash -c "gpg --home /var/lib/passbolt/.gnupg --import /etc/passbolt/gpg/serverkey_private.asc" www-data
 [PASS] There is a valid email id defined for the server key.

```

So now I don’t know what we could do…

---

<div class="post-metadata">

**Author:** ![Steph](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/steph/32/2348_2.png) [@Steph](https://community.passbolt.com/u/Steph)\
**Post date:** [May 26, 2023, 7:57am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/2 "2023-05-26T07:57:50Z")

</div>

Hello @Fabian and Welcome to the forum.

I took a look at the error and found something on the Internet. It could be the GPG command that needs an extra parameter since a newer version of GNUPG2.

Maybe you can try this instead:

```bash
 sudo su -s /bin/bash -c "gpg --batch --home /var/lib/passbolt/.gnupg --import --verbose --pinentry-mode loopback /etc/passbolt/gpg/serverkey_private.asc" www-data

```

Basically, it’s the same command as before with the extra parameter `--batch`. If it works it means we need to update the help page to reflect that change.

---

<div class="post-metadata">

**Author:** ![Fabian](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@Fabian](https://community.passbolt.com/u/Fabian)\
**Post date:** [May 26, 2023, 8:16am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/3 "2023-05-26T08:16:12Z")

</div>

Hello, thanks for this advise, but still the same error

---

<div class="post-metadata">

**Author:** ![max](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/max/32/1528_2.png) [@max](https://community.passbolt.com/u/max)\
**Post date:** [May 26, 2023, 8:27am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/4 "2023-05-26T08:27:37Z")

</div>

> [@Fabian](#):
>
> `/var/lib/passbolt/.gnupg`  
> `/etc/passbolt/gpg`

Hi,  
Can you check the permission and ownership of the keyring and the two keys inside the second folder please

Thanks!

---

<div class="post-metadata">

**Author:** ![Fabian](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@Fabian](https://community.passbolt.com/u/Fabian)\
**Post date:** [May 26, 2023, 8:33am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/5 "2023-05-26T08:33:50Z")

</div>

Yeah sure,

![image](https://canada1.discourse-cdn.com/flex031/uploads/passbolt/original/2X/1/15f3136190c321c49e12cb02cc7c45f65bea90f3.png)

---

<div class="post-metadata">

**Author:** ![max](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/max/32/1528_2.png) [@max](https://community.passbolt.com/u/max)\
**Post date:** [May 26, 2023, 8:41am UTC](https://community.passbolt.com/t/after-upgrade-on-new-server-private-key-not-valid/7540/6 "2023-05-26T08:41:45Z")

</div>

Can you do a  
`chown www-data:www-data /var/lib/passbolt/.gnupg/*`  
And try again please
