Apt でインストールした ROS の gpg がエラーになる

apt update すると下記の警告がでるようになった。参考リンクによると今月に入ってから、らしい。

おおよそ GPG キーの期限切れだろうと予測していたが (サードパーティの apt リポジトリを追加していると比較的出くわす) がその通りだった。

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.ros.org/ros2/ubuntu noble InRelease: The following signatures were invalid: EXPKEYSIG F42ED6FBAB17C654 Open Robotics <info@osrfoundation.org>
W: Failed to fetch http://packages.ros.org/ros2/ubuntu/dists/noble/InRelease  The following signatures were invalid: EXPKEYSIG F42ED6FBAB17C654 Open Robotics <info@osrfoundation.org>
W: Some index files failed to download. They have been ignored, or old ones used instead.

GPG キーを入れ替えればいいだけなのだが、URL がわからなかったのでメモする。

鍵は https://raw.githubusercontent.com/ros/rosdistro/master/ros.key にあるようなので

curl -sS https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o ros.key
とか
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key

あとは /etc/apt/sources.list.d にある ROS リポジトリの設定に従って鍵ファイルを配置して(入れ替えて)やれば OK。

自分の場合は、

/etc/apt/sources.list.d/ros2.list にリポジトリを定義してあり、鍵ファイルは

/usr/share/keyrings/ros.gpg

となっていたので、 ros.key を ros.gpg として /usr/share/keyrings に配置してやればいい。

参考

2025年6月以降ROS環境でapt-get updateするときにGPG errorが発生する場合の対処方法