Gitthubのパスワードを削除する
ボーナス-あなたも、私に私にこれについて話すのを見ることができますTwitch Stream
Gitthubのパスワードを削除する
日後にコードを書くことは秘密、接続文字列とより多くのコードを誤って追加されます.もしあなたが私のような場合、彼らはあなたのgithubレポにコミットして、恥ずかしさで生きなければなりません:)このポストでは、私はあなたがすでに秘密を犯したGithubレポから秘密を削除することによってあなたを歩かせます.
第1部-初期設定:
シナリオ:あなたの値でパスワードをコミットした
どうやって修正するの? あなたのローカルディスクにrepoを持っているか、httpsまたはsshで新鮮なコピーをクローン化することを確認してください.SSHを使います 次のように、ミラーオプションを使用して保存された秘密を持っているREPOのコピーをクローンします 今、あなたは少しのrepoがあるでしょう.それにCD 以下は私のレポの例です.
クリエイトア 私はMacOSで私の鉱山を作成
ファイルを保存します. Part 3 - bfgをインストールします.
エンターBFG . 著者によると
インストールBFG with パート4 -以前にコミットしたパスワードをクリーンアップします. ラン 以下はそのコマンドの出力です.
ラン ラン 第6部-ラップアップし、レポが正常に更新されたことを確認します.
github repoに戻って、前のコミットを見ると、次のように* remove *が表示されます.
私は、これは誰かがそこに役立つ場合は、タッチで滞在したい場合は、私は見つけることができます願っていますTwitch , or GitHub .
Gitthubのパスワードを削除する
日後にコードを書くことは秘密、接続文字列とより多くのコードを誤って追加されます.もしあなたが私のような場合、彼らはあなたのgithubレポにコミットして、恥ずかしさで生きなければなりません:)このポストでは、私はあなたがすでに秘密を犯したGithubレポから秘密を削除することによってあなたを歩かせます.
第1部-初期設定:
シナリオ:あなたの値でパスワードをコミットした
qph@}uC,7cGLBdsX
あなたのgithubレポに.このパスワードは秘密でなければならず、コードには格納されません.どうやって修正するの?
git clone [email protected]:mbcrump/crumpbot.git
サンプルとして.git clone --mirror [email protected]:mbcrump/crumpbot.git
. cd crumpbot.git
ランls -l
MacOSのコンテンツを一覧表示するにはdir
Windowsで.[mbcrump@Michaels-MBP-3]:[~/Documents/code]$ cd crumpbot.git
[mbcrump@Michaels-MBP-3]:[~/Documents/code/crumpbot.git] (BARE:master)$ ls -l
total 32
-rw-r--r-- 1 mbcrump staff 23 Dec 1 19:47 HEAD
-rw-r--r-- 1 mbcrump staff 211 Dec 1 19:47 config
-rw-r--r-- 1 mbcrump staff 73 Dec 1 19:47 description
drwxr-xr-x 13 mbcrump staff 416 Dec 1 19:47 hooks
drwxr-xr-x 3 mbcrump staff 96 Dec 1 19:47 info
drwxr-xr-x 27 mbcrump staff 864 Dec 1 19:48 objects
-rw-r--r-- 1 mbcrump staff 105 Dec 1 19:47 packed-refs
drwxr-xr-x 4 mbcrump staff 128 Dec 1 19:47 refs
Part 2 -削除したいパスワードのファイルを作成します.passwords.txt
ファイルと場所とあなたのgithubレポから削除したいパスワードを入力します.touch passwords.txt
or echo some-text > passwords.txt
Windowsで、誤ってコミットしたパスワードを追加しました.qph@}uC,7cGLBdsX
エンターBFG . 著者によると
BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:
Removing Crazy Big Files
Removing Passwords, Credentials & other Private data
brew install bfg
あなたがhomebrewをインストールして、マックを使うと仮定するか、あるいはdownload あなたがWindowsの上にあるならば、JARファイル.bfg --replace-text passwords.txt crumpbot.git
Macまたはjava -jar bfg.jar --replace-text passwords.txt crumpbot.git
JARファイルを使用する場合.[mbcrump@Michaels-MBP-3]:[~/Documents/code]$ bfg --replace-text passwords.txt crumpbot.git
Using repo : /Users/mbcrump/Documents/code/crumpbot.git
Found 2489 objects to protect
Found 2 commit-pointing refs : HEAD, refs/heads/master
Protected commits
-----------------
These are your protected commits, and so their contents will NOT be altered:
* commit 58969937 (protected by 'HEAD')
Cleaning
--------
Found 11 commits
Cleaning commits: 100% (11/11)
Cleaning commits completed in 96 ms.
Updating 1 Ref
--------------
Ref Before After
---------------------------------------
refs/heads/master | 58969937 | 3f9041c9
Updating references: 100% (1/1)
...Ref update completed in 24 ms.
Commit Tree-Dirt History
------------------------
Earliest Latest
| |
D D D D DD D D m m m
D = dirty commits (file tree fixed)
m = modified commits (commit message or parents changed)
. = clean commits (no changes to file tree)
Before After
-------------------------------------------
First modified commit | 39e68d03 | 95e6f9f4
Last dirty commit | 2007b5c5 | 0f57a693
Changed files
-------------
Filename Before & After
--------------------------------------------------------
bot.js | 1b55a8d0 ⇒ 02758dd8, cba19782 ⇒ db95f8c2, ...
In total, 19 object ids were changed. Full details are logged here:
/Users/mbcrump/Documents/code/crumpbot.git.bfg-report/2019-12-01/19-48-22
BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive
パート5 - Githubへのプッシュgit reflog expire --expire=now --all && git gc --prune=now --aggressive
出力で示されるように.git push
それをあなたのレポにプッシュする.github repoに戻って、前のコミットを見ると、次のように* remove *が表示されます.
var tmi = require("tmi.js")
var channel = "mbcrump"
var config = {
options: {
debug: true
},
connection: {
cluster: "aws",
reconnect: true
},
identity: {
username: "mbcrump",
password: "***REMOVED***"
},
channels: [channel]
}
指摘した通りSuch commits should always be treated as the equivalent of a password leak.
There is no way to guarantee that the exposed passwords have not been copied elsewhere so should always be considered compromised and changed.
私は、これは誰かがそこに役立つ場合は、タッチで滞在したい場合は、私は見つけることができます願っていますTwitch , or GitHub .
Reference
この問題について(Gitthubのパスワードを削除する), 我々は、より多くの情報をここで見つけました https://dev.to/mbcrump/remove-passwords-committed-to-github-on-accident-1oj9テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol