安裝 K6 後apt 無法更新,GPG error 錯誤解決辦法

前陣子安裝K6進行壓力測試後,測試主機就無法自動透過Ubuntu 的 apt 工具來進行更新系統上的套件。

錯誤訊息

apt 更新時會出現以下錯誤訊息,主要問題點在於系統無法驗證Public key 。

W: GPG error: https://dl.k6.io/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C780D0BDB1A69C86
E: The repository 'https://dl.k6.io/deb stable InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解決步驟

先刪除原本的K6驗證Key

$ sudo apt-key del k6

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

重新匯入新的驗證key


$ sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
gpg: WARNING: unsafe permissions on homedir '/root/.gnupg'
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 77C6C491D6AC1D69: public key "k6.io (key for signing binaries) <security@k6.io>" imported
gpg: Total number processed: 1
gpg:               imported: 1

顯示錯誤

如果匯入key時顯示沒有 /root/.gnupg/ 這個路徑,可以透過以下方式解決。

gpg: failed to create temporary file '/root/.gnupg/.#lk0x0000558ad9bd40c0.cjk.33516': No such file or directory
gpg: connecting dirmngr at '/root/.gnupg/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr

新增路徑來讓指令可以正常執行

$ sudo mkdir /root/.gnupg/

重新將key 與apt 軟體驗證設定在一起

cjk@cjk:~$ echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list

deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main

以上都處理完畢後就可以正常apt更新了

參考來源:

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

返回頂端