Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Security concerns when using git as a deployment utility

git is a very powerful tool, but not that easy to use

For example, I am glad to use git as a tool to update my remote site from my git repository. The problem is there is a .git directory at the root of my website, external users can simply visit it using site/.git, that is terrible, since they can easily get my code history, and basically the current code, they can even get passwords and private informations from the configuration files.

So what is the right way to use git which can make full use of git, but without introducing these threats?

Using git clone git://repo site_root to initialize web site, and git pull to get changes is of great convenience, but also brings huge security problems.

Is there any methods that can be as convenient as the steps shown above, but without security pitfalls?

like image 892
thinke365 Avatar asked May 19 '26 20:05

thinke365


1 Answers

Apache, at least, defaults its configuration to forbidding web access to any file starting with a ., and this could be done in any other webserver as well.

Additionally, it's best to keep sensitive files outside the web root, i.e.:

.git/
config.file
public/
public/index.html

and have the document root for the site be the public/ directory.

like image 112
ceejayoz Avatar answered May 21 '26 15:05

ceejayoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!