最近在VPS中使用apt-get update命令時,出現了如下的錯誤,形式如“W: GPG error: http://security.ubuntu.com trusty-security Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY XXXXX”
該問題也會出現在Ubuntu其他的版本中,實際上在商家上線的系統模版中或多或少都有一些類似的細節錯誤,值得我們在使用中注意並修正。當然這一類的問題實際上並不算大,只是解決起來可能需要一些搜索工作。
apt-get update返回NO_PUBKEY錯誤的解決方法
報錯代碼如下:
Err:5 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu bionic InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3F01618A51312F3F Fetched 23.3 kB in 9s (2,673 B/s) Reading package lists... Done W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3F01618A51312F3F W: Failed to fetch https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/bionic/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3F01618A51312F3F W: Some index files failed to download. They have been ignored, or old ones used instead.
解決辦法:
將公鑰添加至服務器,運行如下命令解決:
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
添加成功后終端輸出為:
Executing: /tmp/apt-key-gpghome.4JQ9tOjCB7/gpg.1.sh --recv-keys --keyserver keyserver.ubuntu.com 3F01618A51312F3F gpg: key 3F01618A51312F3F: public key "GitLab B.V. (package repository signing key) <packages@gitlab.com>" imported gpg: Total number processed: 1 gpg: imported: 1
這樣再去sudo apt-get update就不會有問題了。