以下の内容はhttps://souiunogaii.hatenablog.com/entry/GitLab-gpgkeyより取得しました。


GitLabがGPG鍵のエラーで更新できないときの対処方法

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・GitLabがGPG鍵のエラーで更新できないので対処方法を知りたい。
・具体的な手順を教えてほしい。

こういった疑問に答えます。

本記事の内容

  1. GitLabがGPG鍵のエラーで更新できないときの対処方法

サトナカ (@souiunogaii)

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

GitLabがGPG鍵のエラーで更新できないときの対処方法

事象

https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey (0x51312F3F) の GPG 鍵はインストール済みです
gitlab_gitlab-ce                                                     23 kB/s | 7.0 kB     00:00
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg (0xF27EAB47) の GPG 鍵はインストール済みです
"gitlab_gitlab-ce" リポジトリーに一覧表示されている GPG 鍵はインストール済みですが、このパッケージには適切ではありません。
正しい鍵 URL がこのリポジトリー用に設定されているか確認してください。. 失敗したパッケージは: gitlab-ce-18.1.1-ce.0.el8.x86_64
 GPG 鍵が設定されています: https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey, https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
ダウンロード済みのパッケージは、次の正常なトランザクションまでキャッシュに保存されました。
'dnf clean packages' を実行することでキャッシュパッケージを削除できます。
エラー: GPG の確認に失敗しました

関連するページ

docs.gitlab.com

・上記のページにある手順の通りに対応してみます。

対処方法

インストール済のGPG鍵を探す

$ rpm -qa | grep -i F27EAB47
gpg-pubkey-f27eab47-664d1fe3

$ rpm -qa | grep -i 51312F3F
gpg-pubkey-51312f3f-65df946d

インストール済のGPG鍵を削除

$ sudo rpm -e gpg-pubkey-f27eab47-664d1fe3
$ sudo rpm -e gpg-pubkey-51312f3f-65df946d
$ rpm -qa | grep -i 51312F3F
$ rpm -qa | grep -i F27EAB47

リポジトリ データとキャッシュを更新

dnf check-update
$ dnf check-update
Rocky Linux 8 - AppStream                                           3.5 MB/s |  19 MB     00:05
Rocky Linux 8 - BaseOS                                              1.4 MB/s |  27 MB     00:19
Rocky Linux 8 - Extras                                               11 kB/s |  15 kB     00:01
gitlab_gitlab-ce                                                    399  B/s | 862  B     00:02
gitlab_gitlab-ce                                                    7.3 kB/s | 3.1 kB     00:00
GPG 鍵 0x51312F3F をインポート中:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: F640 3F65 44A3 8863 DAA0 B6E0 3F01 618A 5131 2F3F
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
これでよろしいですか? [y/N]: y  ←★★★yを入力
gitlab_gitlab-ce                                                     22 kB/s | 7.0 kB     00:00
GPG 鍵 0xF27EAB47 をインポート中:
 Userid     : "GitLab, Inc. <support@gitlab.com>"
 Fingerprint: DBEF 8977 4DDB 9EB3 7D9F C3A0 3CFC F9BA F27E AB47
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
これでよろしいですか? [y/N]: N  ←●●●Nを入力
gitlab_gitlab-ce                                                    822 kB/s | 3.0 MB     00:03
gitlab_gitlab-ce-source                                             687  B/s | 862  B     00:01
gitlab_gitlab-ce-source                                             7.4 kB/s | 3.1 kB     00:00
GPG 鍵 0x51312F3F をインポート中:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: F640 3F65 44A3 8863 DAA0 B6E0 3F01 618A 5131 2F3F
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
これでよろしいですか? [y/N]: y  ←★★★yを入力
gitlab_gitlab-ce-source                                             102  B/s | 296  B     00:02

新しいGPG鍵をダウンロード

curl "https://packages.gitlab.com/gpg.key" -o /tmp/omnibus_gitlab_gpg.key
$ sudo curl "https://packages.gitlab.com/gpg.key" -o /tmp/omnibus_gitlab_gpg.key
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3191    0  3191    0     0  11603      0 --:--:-- --:--:-- --:--:-- 11561

新しいGPG鍵をインポート

$ sudo rpm --import /tmp/omnibus_gitlab_gpg.key

パーミッションを644に変更

$ sudo chmod 644 /tmp/omnibus_gitlab_gpg.key

GitLabの公開鍵が存在するかどうか確認

rpm -q gpg-pubkey-82dd593d-67aefdd8 --qf '%{name}-%{version}-%{release} --> %{summary}'
$ sudo rpm -q gpg-pubkey-82dd593d-67aefdd8 --qf '%{name}-%{version}-%{release} --> %{summary}'
パッケージ gpg-pubkey-82dd593d-67aefdd8 はインストールされていません。

存在しないのでインポート

$ sudo rpm --import https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-git
lab-ce-CB947AD886C8E8FD.pub.gpg

リポジトリ ファイルが存在するかどうかを確認

$ sudo file /etc/yum.repos.d/gitlab_gitlab-ce.repo
/etc/yum.repos.d/gitlab_gitlab-ce.repo: ASCII text

署名チェックがアクティブであることを確認

/etc/yum.repos.d/gitlab_gitlab-ce.repo
[gitlab_gitlab-ce]
name=gitlab_gitlab-ce
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/8/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[gitlab_gitlab-ce-source]
name=gitlab_gitlab-ce-source
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/8/SRPMS
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

再度、更新を実施

dnf update gitlab-ce
$ sudo dnf update gitlab-ce
gitlab_gitlab-ce                                                    520  B/s | 862  B     00:01
gitlab_gitlab-ce-source                                             533  B/s | 862  B     00:01
メタデータの期限切れの最終確認: 0:00:01 前の 20250629073111秒 に実施しました。
依存関係が解決しました。
====================================================================================================
 パッケージ          アーキテクチャー バージョン                   リポジトリー               サイズ
====================================================================================================
アップグレード:
 gitlab-ce           x86_64           18.1.1-ce.0.el8              gitlab_gitlab-ce           1.4 G

トランザクションの概要
====================================================================================================
アップグレード  1 パッケージ

(中略)


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Upgrade complete! If your GitLab server is misbehaving try running
  sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).


  検証中           : gitlab-ce-18.1.1-ce.0.el8.x86_64                                           1/2
  検証中           : gitlab-ce-18.0.1-ce.0.el8.x86_64                                           2/2

アップグレード済み:
  gitlab-ce-18.1.1-ce.0.el8.x86_64

完了しました!

やったぜ!




以上の内容はhttps://souiunogaii.hatenablog.com/entry/GitLab-gpgkeyより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14