Web Dev full-stack [LAMP] since 2005, but much heavier on the JS stuff these days.
Jack of all Stacks, Master of some.
Always looking to learn new things. Always glad to help out, just ask.
Location
Atlanta, GA
Education
B.S. in Biochemistry 2004, M.S. in Computer Information Systems 2007
It's not worth doing all that though.
Just make sure it's in the gitignore and doesn't get added anymore.
AND go and change all the credentials you accidentally leaked.
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
Web Dev full-stack [LAMP] since 2005, but much heavier on the JS stuff these days.
Jack of all Stacks, Master of some.
Always looking to learn new things. Always glad to help out, just ask.
Location
Atlanta, GA
Education
B.S. in Biochemistry 2004, M.S. in Computer Information Systems 2007
There is nothing wrong with doing that. It's just more effort AND if you don't do it right there will still be some branch/commit/version up there that has your old creds.
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
This sounds opinion based and isn't the case for everyone. Depending on the level of compliance it is necessary to remove this information from your GitHub history. Its fine if you personally don't want to remove your leaked secrets, but that is simply not an option for everyone.
Web Dev full-stack [LAMP] since 2005, but much heavier on the JS stuff these days.
Jack of all Stacks, Master of some.
Always looking to learn new things. Always glad to help out, just ask.
Location
Atlanta, GA
Education
B.S. in Biochemistry 2004, M.S. in Computer Information Systems 2007
Great Article , If you dont mind me asking , where should i store my .env information other than github as a backup do you have a tool in mind or similar that organizes your .env files ? because from my end i just keep the .env file and make the repo private , And thank you in advance for your time for reading my question.
You may want to keep the sensitive credentials (oAuth tokens, etc.) in a password manager or similarly secure place, rather than any typical backup method
I like to create a SAMPLE.env file that contains all of the non-sensitive variables, along with comments about each variable, and a just a placeholder for any oAuth tokens or other credentials. I let this file make it into the repo by design. (Don't put *.env in the .gitignore, just .env as described in the article above to ensure SAMPLE.env is not ignored).
This gives me a backup of the entire file (minus the secrets) right in the repo, and serves as a template/quick-start for other users of the code.
Whether you are recovering from a drive loss, setting up on another computer, or another developer is using your code, you simply copy SAMPLE.env .env and update the placeholdes with the credentials.
I agree with @brian_rlist_c3025e6dbb I found the simplest solution is to store the file in a Keypass database and use a backup tool to backup the database and if you want to get fancy use the keypass cli to export it before build and deploy but thats optional
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
I know that there is some debate going on in the comment section right now about how "unimportant" it is to remove history or rewrite the GitHub history after credentials are leaked. Yes, this is an optional thing no one is forcing you to do this. It's not something that anyone is "required" to do, but I have looked into this and having this information floating around out there can have its drawbacks. All debatable yes, so do your own research and decide for yourself.
Linking yet another resource with a quote here for those who are not 100% convinced on removing leaked secrets.
"Once the secret has been revoked, it cannot be used anymore. Nonetheless, having credentials, even expired ones, could look unprofessional and raise concerns. Additionally, some secrets cannot be revoked (for example, database records), or credentials no one can guarantee were properly revoked (for example, SSH keys that can be used in many different places). While we will go through the steps of how to remove secrets from the git history, please note that this is not a trivial task, and it is advised to seek the guidance of a senior developer."
If you're planning to put tokens which can be regenerated, removing the .env file entirely from the git history is worthless. Just regenerating the credentials and adding the file to the ignored list should work wonders.
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
I'm just now checking up on the comments here, it's been a long week.
Thank you all so much for your kind words about the article! 😄
For storing .env files securely, there are a few different options for encryption tools like EncFS for local backups or services like HashiCorp Vault for more advanced secret management. If you're looking for organization, using environment-specific .env files (like .env.development) combined with a tool like direnv could be very beneficial.
Remember to try and never commit these files to GitHub, even in private repos, and use .gitignore to exclude them. Hope this helps!
I am an expert software engineer with over a decade experience in the Web development industry. My main focus is to develop front-end solutions with JavaScript, Angular or React technical stack.
Karmen is an SWE. Beyond the code, Karmen is a connoisseur of experiences. From savoring flaming hot ramen to indulging in late-night gaming escapades, her many interests enrich her outlook on life.
Location
Asheville, North Carolina
Education
UOPX BSCOM - 2018 | BloomTech FS SWE 2021
Work
Software Engineer + Creative Technologist + Solo Game Dev
Yes GitHub is indeed snapshot based but that is why we are pruning the history in step two to rewrite the commit history. That is the entire point of this blog post. You can find more information here in the official documentation.
It's not worth doing all that though.
Just make sure it's in the gitignore and doesn't get added anymore.
AND go and change all the credentials you accidentally leaked.
And move on. It happens :)
Agreed with @ravavyr .
Point #5 (revoking leaked credentials) should be #1 .
The rest are optional (but recommended) steps.
I would personally still remove the history of the leaked file from GitHub to be safe. ;)
There is nothing wrong with doing that. It's just more effort AND if you don't do it right there will still be some branch/commit/version up there that has your old creds.
This sounds opinion based and isn't the case for everyone. Depending on the level of compliance it is necessary to remove this information from your GitHub history. Its fine if you personally don't want to remove your leaked secrets, but that is simply not an option for everyone.
Everything we do is opinion based, lol.
Great Article , If you dont mind me asking , where should i store my .env information other than github as a backup do you have a tool in mind or similar that organizes your .env files ? because from my end i just keep the .env file and make the repo private , And thank you in advance for your time for reading my question.
You may want to keep the sensitive credentials (oAuth tokens, etc.) in a password manager or similarly secure place, rather than any typical backup method
I like to create a
SAMPLE.envfile that contains all of the non-sensitive variables, along with comments about each variable, and a just a placeholder for any oAuth tokens or other credentials. I let this file make it into the repo by design. (Don't put*.envin the.gitignore, just.envas described in the article above to ensureSAMPLE.envis not ignored).This gives me a backup of the entire file (minus the secrets) right in the repo, and serves as a template/quick-start for other users of the code.
Whether you are recovering from a drive loss, setting up on another computer, or another developer is using your code, you simply
copy SAMPLE.env .envand update the placeholdes with the credentials.I agree with @brian_rlist_c3025e6dbb I found the simplest solution is to store the file in a Keypass database and use a backup tool to backup the database and if you want to get fancy use the keypass cli to export it before build and deploy but thats optional
vaultproject.io/
github.com/AGWA/git-crypt
🥴 Just going to link over to this blog post now.
I know that there is some debate going on in the comment section right now about how "unimportant" it is to remove history or rewrite the GitHub history after credentials are leaked. Yes, this is an optional thing no one is forcing you to do this. It's not something that anyone is "required" to do, but I have looked into this and having this information floating around out there can have its drawbacks. All debatable yes, so do your own research and decide for yourself.
Linking yet another resource with a quote here for those who are not 100% convinced on removing leaked secrets.
What to do after leaking credentials and API keys
"Once the secret has been revoked, it cannot be used anymore. Nonetheless, having credentials, even expired ones, could look unprofessional and raise concerns. Additionally, some secrets cannot be revoked (for example, database records), or credentials no one can guarantee were properly revoked (for example, SSH keys that can be used in many different places). While we will go through the steps of how to remove secrets from the git history, please note that this is not a trivial task, and it is advised to seek the guidance of a senior developer."
I agree with others, that removing the leaked file from GitHub is a safe move.
Thanks a lot!!!
If you're planning to put tokens which can be regenerated, removing the .env file entirely from the git history is worthless. Just regenerating the credentials and adding the file to the ignored list should work wonders.
Thanks for the comment. I linked a few resources that detail when removing the history may be necessary. This is not a one size fits all situation.
👋🏽 Hey everyone, thanks for the comments!
I'm just now checking up on the comments here, it's been a long week.
Thank you all so much for your kind words about the article! 😄
For storing .env files securely, there are a few different options for encryption tools like EncFS for local backups or services like HashiCorp Vault for more advanced secret management. If you're looking for organization, using environment-specific .env files (like .env.development) combined with a tool like direnv could be very beneficial.
Remember to try and never commit these files to GitHub, even in private repos, and use .gitignore to exclude them. Hope this helps!
Well, you can't delete data from Github, because Git is snapshot based VCS trufflesecurity.com/blog/anyone-ca...
Yes GitHub is indeed snapshot based but that is why we are pruning the history in step two to rewrite the commit history. That is the entire point of this blog post. You can find more information here in the official documentation.
Removing Sensitive Data from GitHub