แก้ไข apt-get update เมื่อ trusted keys หายไป

แก้ไข apt-get update เมื่อ trusted keys หายไป

พอดีได้ไปเจอเครื่อง ubuntu ที่มันไม่สามารถเรียก apt-get update ได้ มัน error ประมาณนี้ "the following signatures couldn’t be verified because the public key is not available"

$ sudo apt-get update
Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
...
Fetched 21.9 MB in 14s (1,537 kB/s)
Reading package lists... Done
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 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.canonical.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32

เมื่อดูข้อผิดพลาดด้านบน apt กำลังบอกเราว่าคีย์ต่อไปนี้หายไป 40976EAF437D05B5 และ 3B4FE6ACC0B21F32 สังเกตว่ามันถูกระบุไว้หลายครั้ง เราแก้ไขได้ดังนี้

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.QTeppiINUh --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: key 437D05B5: public key "Ubuntu Archive Automatic Signing Key " imported
gpg: Total number processed: 1
gpg:               imported: 1

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.77TqYGKU7b --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
gpg: requesting key C0B21F32 from hkp server keyserver.ubuntu.com
gpg: key C0B21F32: public key "Ubuntu Archive Automatic Signing Key (2012) " imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

เพียงเท่านี้เราก็สามารถ apt-get update ได้อีกครั้ง...

Arnon Kijlerdphon

Arnon Kijlerdphon

Choosing to live a plant-based lifestyle for the animals, my health, and the future of our planet.
Bangkok, Thailand