サーバーのタイムゾーン設定が原因でSSMがエラーになっていた

Posted date at 2024-01-22

AWS

概要


諸事情によってRockey Linuxを利用してリモートに開発環境を作成し開発を行っています。

この開発用サーバーからセルフホストのGitLabサーバーへ通信する際にAWS SSMを立ち上げています。

aws ssm start-session --target i-xxxxxxxxxxxxx --document-name AWS-StartPortForwardingSession --parameters portNumber="xxx",localPortNumber="xxxxx"

このようなコマンドを実行すると403エラーが発生していました。

An error occurred (403) when calling the StartSession operation: Server authentication failed: <UnauthorizedRequest xmlns=""><message>Forbidden.</message></UnauthorizedRequest>

この解決にLinuxサーバーのローカルタイムゾーンの設定が原因だと判断するまでに時間がかかってしまったので備忘録として残します

環境

$ cat /etc/os-release NAME="Rocky Linux" VERSION="9.3 (Blue Onyx)" ID="rocky" ID_LIKE="rhel centos fedora" VERSION_ID="9.3" PLATFORM_ID="platform:el9" PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)" ANSI_COLOR="0;32" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:rocky:rocky:9::baseos" HOME_URL="https://rockylinux.org/" BUG_REPORT_URL="https://bugs.rockylinux.org/" SUPPORT_END="2032-05-31" ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9" ROCKY_SUPPORT_PRODUCT_VERSION="9.3" REDHAT_SUPPORT_PRODUCT="Rocky Linux" REDHAT_SUPPORT_PRODUCT_VERSION="9.3"

IAMユーザーの権限などには問題がない状態。

解決策


sudo yum update sudo systemctl start chronyd sudo reboot

Chronydが有効化されておらず、ローカルタイムゾーンが8時間以上ずれていた。

Chronydによって時間を同期させることでSSMのエラーを解決することができました。

参考

【RHEL8/CentOS8】NTPは死んだ。時代はChrony。

https://qiita.com/thzking/items/c2bcf7d60963b4dab7b6

chrony の概要および設定

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-understanding_chrony_and-its_configuration#doc-wrapper

←ホームに戻る