Cannot login into private hub: Unusable public key

I have setup my own private hub repository as described in this post.

The hub repository has been setup with several users/passwords (using htpasswd).

I have no issue login into that remote repository from a local client when there is the same PGP private sub-key on both hosts for the same user account sharing obviously the same email address.

What I’m trying to do is access the same remote hub repository from a different client host using a different user account with a different PGP private key and a different email address.

Unfortunately, it does not seem possible on the second client:

# pass init 0E9BCA1BEED5D56D
mkdir: created directory '/root/.password-store/'
Password store initialized for 0E9BCA1BEED5D56D
# echo "$hub_password" | docker login --username $hub_user --password-stdin ${hub_fqdn}
error saving credentials: error storing credentials - err: exit status 1, out: `exit status 1: gpg: 0E9BCA1BEED5D56D: skipped: Unusable public key
gpg: [stdin]: encryption failed: Unusable public key
Password encryption aborted.`

What is going on? How can I make it work?

Just to be sure, by “Hub repository”, do you mean Docker Hub, or any other container image registry? We talked about registry:3.0 in the other topic.

Why you get the error, that is a mystery to me. Or almost. Other, not Docker-related sources mention that it can happen when the key is not trusted

Docker hub

The key is trusted as it is created on the client host.

However, I’ve discovered a bug in gpg2 when creating a private key with the ‘—batch’ option: the subkey usage is… empty! That explains the error message Unusable public key

So I recreated the private key manually this time, and the subkey default usage is E (encrypt) now.

Nevertheless, there is now another issue:

echo "$hub_password" | docker login --username $hub_user --password-stdin ${hub_fqdn}
Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: incorrect username or password

I know that both username and password are correct since I can login from the first client host without any issue with the same credentials.

The difference between both client hosts is that the second client host does not have the gpg private key that was used to initialize the hub repository.

That is a major issue: it seems that it is impossible to login from different client hosts unless they all have the same gpg private key that was used for the hub server. That is not usable at all.

Again, I’m trying to share a private hub registry between different clients. They must be a way to achieve that without the constraint to distribute the same private key on all hosts.