LoginSignup
2
4

More than 5 years have passed since last update.

git-secretsを使って、誤ってgitでawsの鍵情報を公開しないようにする

Posted at

git-secrets

awsを使っているとaws-cliやsdkを使い鍵情報が必要になり、鍵の管理がとても大事になる。
誤ってgitで公開しないように対策するためにgit-secretsを導入した。

インストール

  • install
    • 環境: MacOS ( High Sierra )
$ brew install git-secrets`
$ curl -O https://raw.githubusercontent.com/awslabs/git-secrets/master/git-secrets`
$ chmod +x ./git-secrets
$ git secrets --register-aws --global
  • .gitconfigを確認
    • ~/.gitconfig
    • 許可するAWSの鍵が定義されている(ここに公開したくない鍵情報を定義する)

方法1 ( 手動スキャンでチェックする )

  • $ git secrets --scan --no-index
[ERROR] Matched one or more prohibited patterns

方法2 ( commit時に自動チェックする )

  • $ git secrets --install
✓ Installed commit-msg hook to .git/hooks/commit-msg
✓ Installed pre-commit hook to .git/hooks/pre-commit
✓ Installed prepare-commit-msg hook to .git/hooks/prepare-commit-msg
~/hoge ❯❯❯ ls
test-key
~/hoge ❯❯❯ git add test-key
~/hoge ❯❯❯ git commit -m "test key check"

[ERROR] Matched one or more prohibited patterns
2
4
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
2
4