Last active
          October 31, 2024 15:14 
        
      - 
      
- 
        Save turboBasic/29d00adf652aa0a8a582478c95cd566a to your computer and use it in GitHub Desktop. 
Revisions
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,8 @@ Requirements 1. [GnuPG](https://www.gnupg.org) aka "gpg" 2. [git-crypt](https://github.com/AGWA/git-crypt) > you may totally ignore complicated gpg manuals, but you must understand how `git-crypt` operates. <br/> > `gpg` 2.2+ uses AES256 by default, so your secrets are fully depend on the passphrase you are going to use. Prepare repository for encryption --------------------------------- 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ Use git-crypt & symmetric key kept inside a repo to encrypt some files in the repository ======================================================================================== Requirements ------------ 1. [GnuPG](https://www.gnupg.org) aka "gpg" 2. [git-crypt](https://github.com/AGWA/git-crypt) > you may totally ignore complicated gpg manuals, but you must understand how git-crypt is working. > gpg 2.2+ uses AES256 by default, so your secrets are fully depend on the passphrase you are going to use Prepare repository for encryption --------------------------------- 
- 
        turboBasic revised this gist Nov 28, 2018 . No changes.There are no files selected for viewing
- 
        turboBasic renamed this gist Nov 28, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Prepare repository for encryption mkdir encrypted-repo && cd encrypted-repo git init && git-crypt init curl --user GITHUB_NAME https://api.github.com/user/repos --data '{ "name": "encrypted-repo" }' && \ git remote add origin https://github.com/GITHUB_NAME/encrypted-repo.git ``` ### Encrypt just generated key using GPG and your super-password, save it as `local.key.asc` 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,11 +16,10 @@ Prepare repository for encryption ### Create repository & initialize encryption with git-crypt ```bash mkdir encrypted-repo && cd encrypted-repo git init && git-crypt init curl --user GITHUB_NAME https://api.github.com/user/repos --data '{ "name": "encrypted-repo" }' && \ git remote add origin https://github.com/GITHUB_NAME/my-encrypted-repo.git ``` ### Encrypt just generated key using GPG and your super-password, save it as `local.key.asc` @@ -57,8 +56,7 @@ Decrypt repository in the new location ### Clone & enter repo ```bash git clone https://github.com/GITHUB_NAME/encrypted-repo.git && cd encrypted-repo ``` ### Decrypt key by GPG and decrypt repo with it 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Requirements Prepare repository for encryption --------------------------------- > :skull::skull::skull: <br/> > ¡ instructions are intentionally provided for empty repository, otherwise it cannot be guaranteed that files you are going to encrypt haven't been leaked to the repo in previous commits ! ### Create repository & initialize encryption with git-crypt @@ -48,8 +48,8 @@ Usage Follow your usual git workflow, git-crypt will take care of transparent encryption of selected files. When you need the new file to be encrypted, add it to `.gitattributes` as stated in [Add files which need to be encrypted to `.gitattributes`](#add-files-which-need-to-be-encrypted-to-gitattributes). > :skull::skull::skull: <br/> > ¡¡¡ Do it before adding with `git add` otherwise non-encrypted file will be committed & pushed to the Internet !!! Decrypt repository in the new location 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,8 @@ Requirements Prepare repository for encryption --------------------------------- > :skull::skull::skull: > ¡ instructions are intentionally provided for empty repository, otherwise it cannot be guaranteed that files you are going to encrypt haven't been leaked to the repo in previous commits ! ### Create repository & initialize encryption with git-crypt ```bash @@ -47,7 +48,8 @@ Usage Follow your usual git workflow, git-crypt will take care of transparent encryption of selected files. When you need the new file to be encrypted, add it to `.gitattributes` as stated in [Add files which need to be encrypted to `.gitattributes`](#add-files-which-need-to-be-encrypted-to-gitattributes). > :skull::skull::skull: > ¡¡¡ Do it before adding with `git add` otherwise non-encrypted file will be committed & pushed to the Internet !!! ** Decrypt repository in the new location 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Use symmetric key kept in the repo to encrypt the repo Requirements ------------ 1. [GnuPG](https://www.gnupg.org) aka "gpg" 2. [git-crypt](https://github.com/AGWA/git-crypt) @@ -18,8 +18,8 @@ Prepare repository for encryption mkdir my-encrypted-repo cd my-encrypted-repo git init && git-crypt init curl --user YOUR_GITHUB_NAME https://api.github.com/user/repos --data '{"name":"my-encrypted-repo"}' && \ git remote add origin https://github.com/YOUR_GITHUB_NAME/my-encrypted-repo.git ``` ### Encrypt just generated key using GPG and your super-password, save it as `local.key.asc` 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Requirements Prepare repository for encryption --------------------------------- > :skull::skull::skull: ¡ instructions are intentionally provided for empty repository, otherwise it cannot be guaranteed that files you are going to encrypt haven't been leaked to the repo in previous commits ! ### Create repository & initialize encryption with git-crypt ```bash @@ -45,7 +45,9 @@ Usage ----- Follow your usual git workflow, git-crypt will take care of transparent encryption of selected files. When you need the new file to be encrypted, add it to `.gitattributes` as stated in [Add files which need to be encrypted to `.gitattributes`](#add-files-which-need-to-be-encrypted-to-gitattributes). > ** :skull::skull::skull: ¡¡¡ Do it before adding with `git add` otherwise non-encrypted file will be committed & pushed to the Internet !!! ** Decrypt repository in the new location 
- 
        turboBasic revised this gist Nov 28, 2018 . 1 changed file with 39 additions and 30 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,56 +1,65 @@ Use symmetric key kept in the repo to encrypt the repo ====================================================== Requirements ------------ 1. [GnuPG](https://www.gnupg.org) aka `gpg` 2. [git-crypt](https://github.com/AGWA/git-crypt) Prepare repository for encryption --------------------------------- > ¡ :skull: instructions are intentionally provided for empty repository, otherwise it cannot be guaranteed that files you are going to encrypt haven't been leaked to the repo in previous commits ! ### Create repository & initialize encryption with git-crypt ```bash mkdir my-encrypted-repo cd my-encrypted-repo git init && git-crypt init curl --user YOUR_GITHUB_USER_NAME https://api.github.com/user/repos --data '{"name":"my-encrypted-repo"}' && \ git remote add origin https://github.com/YOUR_GITHUB_USER_NAME/my-encrypted-repo.git ``` ### Encrypt just generated key using GPG and your super-password, save it as `local.key.asc` ```bash git-crypt export-key -- - | gpg --symmetric --armor --output local.key.asc ``` ### Add files which need to be encrypted to `.gitattributes` ```bash echo "secretfile filter=git-crypt diff=git-crypt" >> .gitattributes echo "secretfile2 filter=git-crypt diff=git-crypt" >> .gitattributes ``` ### Commit encrypted key, `.gitattributes` and `.gitignore`, set upsream tracking reference ```bash git add local.key.asc .gitattributes .gitignore git commit --message="Config: git-crypt settings" git push --set-upstream origin master ``` Usage ----- Follow your usual git workflow, git-crypt will take care of transparent encryption of selected files. When you need the new file to be encrypted, add it to `.gitattributes` as stated in [Add files which need to be encrypted to `.gitattributes`](#add-files-which-need-to-be-encrypted-to-gitattributes). ** :skull: Do it before adding with `git add` otherwise non-encrypted file will be committed & pushed to the Internet ** Decrypt repository in the new location ------------------------------------ ### Clone & enter repo ```bash git clone https://github.com/you/your-repo.git cd your-repo ``` ### Decrypt key by GPG and decrypt repo with it ```bash gpg --decrypt local.key.asc | git-crypt unlock - ``` ### You are done :sunglasses: :beers: ! 
- 
        turboBasic revised this gist Nov 26, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ cd repo git-crypt init ``` 2. Add files which need to be encrypted to `.gitattributes` ```bash echo "secretfile1.txt filter=git-crypt diff=git-crypt" >> .gitattributes echo "secretfile2.txt filter=git-crypt diff=git-crypt" >> .gitattributes @@ -27,7 +27,7 @@ git add .gitattributes .gitignore git commit -m "Config: git-crypt settings" ``` 5. Encrypt repo using `git-crypt` & encrypt git-crypt's key using GPG and your secret well-known password ```bash git-crypt export-key local.key gpg --symmetric --armor local.key @@ -40,7 +40,7 @@ git commit -m "Config: add symmetric encryption key" Decrypt repository on a new location ------------------------------------ 1. Clone & enter repo ```bash git clone https://github.com/you/your-repo.git cd your-repo 
- 
        turboBasic revised this gist Nov 26, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ git add .gitattributes .gitignore git commit -m "Config: git-crypt settings" ``` 5. Encrypt repo using git-crypt & encrypt git-crypt's key using GPG and your secret well-known password ```bash git-crypt export-key local.key gpg --symmetric --armor local.key 
- 
        turboBasic revised this gist Nov 26, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,4 +53,4 @@ git-crypt unlock local.key rm local.key ``` 3. You are done :sunglasses: ! 
- 
        turboBasic revised this gist Nov 26, 2018 . 1 changed file with 26 additions and 4 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,31 +4,53 @@ Use symmetric key to encrypt repository Encrypt using symmetric key and keep the key in the repository -------------------------------------------------------------- 1. Initialize git-crypt in the repository ```bash cd repo git-crypt init ``` 2. Add files which need to be encrypted to .gitattributes ```bash echo "secretfile1.txt filter=git-crypt diff=git-crypt" >> .gitattributes echo "secretfile2.txt filter=git-crypt diff=git-crypt" >> .gitattributes ``` 3. Add `local.key` to `.gitignore` to avoid pushing unencrypted key ```bash echo local.key >> .gitignore ``` 4. Commit `.gitattributes` and `.gitignore` ```bash git add .gitattributes .gitignore git commit -m "Config: git-crypt settings" ``` 5. Encrypt repo using git-crypt & encrypt they key using GPG and your password ```bash git-crypt export-key local.key gpg --symmetric --armor local.key rm local.key git add local.key.asc git commit -m "Config: add symmetric encryption key" ``` Decrypt repository on a new location ------------------------------------ 1. Clone & enter ```bash git clone https://github.com/you/your-repo.git cd your-repo ``` 2. Decrypt key by GPG and decrypt repo by it ```bash gpg --decrypt local.key.asc > local.key git-crypt unlock local.key rm local.key ``` 3. You are done :smile: ! 
- 
        turboBasic created this gist Nov 26, 2018 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ Use symmetric key to encrypt repository ======================================= Encrypt using symmetric key and keep the key in the repository -------------------------------------------------------------- 1. `cd repo; git-crypt init` 2. Add files which need to be encrypted to .gitattributes ```bash echo "secretfile1.txt filter=git-crypt diff=git-crypt" >> .gitattributes echo "secretfile2.txt filter=git-crypt diff=git-crypt" >> .gitattributes ``` 3. Add `local.key` to .gitignore ```bash echo local.key >> .gitignore ``` 4. Commit .gitattributes and .gitignore ```bash git add .gitattributes .gitignore git commit -m "Config: git-crypt settings" ``` 5. Encrypt repo using git-crypt & encrypt they key using GPG and your password ```bash git-crypt init git-crypt export-key local.key gpg --symmetric --armor local.key rm local.key git add local.key.asc git commit -m "Config: add symmetric encryption key" ```