LoginSignup
0
0

AWS CodeCommit クローン時にエラー 資格情報ヘルパー

Posted at

CodeCommitからcloneしようとした際に以下のエラーが出てた。

git clone ssh://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/wildrydes-siteSS
Cloning into 'wildrydes-siteSS'...
kinoko@git-codecommit.ap-northeast-1.amazonaws.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解決

以下の Step 3: Set up the credential helper に記載がありますが、資格情報ヘルパーの設定をしたら動作した。

資格情報ヘルパー?

認証情報ヘルパー(Credential Helper)は、Gitと外部システム間での認証情報の管理をしてくれる。
Gitでは、リモートリポジトリへのアクセス時に認証が必要になることがあるが、毎回認証情報を入力するのは不便なので、認証情報ヘルパーを使用することで、認証情報を安全に保存し、必要時に自動的に提供可能となる。

git config --global credential.helper '!aws codecommit credential-helper $@':

  • aws codecommit credential-helperをGitの認証情報ヘルパーとしてグローバルに設定
  • credential-helperに続く$@は、Gitから認証情報ヘルパーに渡される引数を表す
  • !で始まるコマンドは、シェルコマンドとして実行されることを意味する
  • この設定により、CodeCommitにアクセスする際、AWS CLIが管理する認証情報を使用して自動的に認証を行う

git config --global credential.UseHttpPath true:

  • Gitは通常、ホストレベルで認証情報を保存するが、この設定をtrueにすることで、パスレベル(つまりリポジトリレベル)で認証情報を区別して使用する
  • これは、同じサーバー上に複数のCodeCommitリポジトリがある場合に特に有用

つまり

これらの設定により、AWS CodeCommitのリポジトリにアクセスする際に、AWSの認証情報(通常はAWS CLIを通じて設定されたもの)を自動的に使用して認証することができます。これにより、リポジトリにアクセスするたびにユーザー名とパスワードを入力する手間が省けるということらしい

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0