【小ネタ】AWS Systems Manager経由でgit cloneする方法

AWS Systems Manager経由で`git clone`しようとしたところ、うまく動作しませんでした。ぴったりの内容が弊社ブログにまとめてあったのですが、Raspberry Pi向けに小ネタとしてコンパクトにまとめました。
2019.11.14

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちはCX事業本部のさかじです。
AWS Systems Manager経由でgit cloneしようとしたところ、うまく動作しませんでした。ぴったりの内容が弊社ブログにまとめてあったのですが、Raspberry Pi向けに小ネタとしてコンパクトにまとめました。
今回問題になった件を詳しく知りたい方は以下のブログを参照ください。
[ハマりまとめ]Session ManagerでAWS CLIを設定してRun Commandで実行しようとした話

環境

  • MacBook Pro(macOS Mojave 10.14.6)
  • Raspberry Pi 3 Model B+

前提条件

Run Commandでgit cloneして失敗

コマンド

git clone git@xxxxx.com:xxxxxx.git"

応答

----------ERROR-------

Cloning into 'xxxxxxxxxxx'...

Host key verification failed.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

failed to run commands: exit status 128

原因

上で紹介したブログの通りrootgit cloneが行われています。
今回使用したいのはpiユーザですので、ユーザ指定してgit cloneを実施します。

解決案

sudo -u pi git clone git@xxxxx.com:xxxxxx.git"

参考サイト

最後に

困ってしまって、調査していたらつい最近それも弊社のブログにぴったりの内容があり非常に助かりました。参考のサイトはEC2関連の情報だったので、Raspberryp Piへの対応を小ネタとしてまとめてみました。