<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>主機管理 &#8211; 這世上 沒有偶然 只有必然</title>
	<atom:link href="https://wordpress.lokidea.com/tag/%e4%b8%bb%e6%a9%9f%e7%ae%a1%e7%90%86/feed/" rel="self" type="application/rss+xml" />
	<link>https://wordpress.lokidea.com</link>
	<description>幻幽的小小分享區</description>
	<lastBuildDate>Wed, 06 Jan 2016 00:30:31 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>使用Git的資安問題【6/366】</title>
		<link>https://wordpress.lokidea.com/431/%e4%bd%bf%e7%94%a8git%e7%9a%84%e8%b3%87%e5%ae%89%e5%95%8f%e9%a1%8c%e3%80%906-366%e3%80%91/</link>
					<comments>https://wordpress.lokidea.com/431/%e4%bd%bf%e7%94%a8git%e7%9a%84%e8%b3%87%e5%ae%89%e5%95%8f%e9%a1%8c%e3%80%906-366%e3%80%91/#respond</comments>
		
		<dc:creator><![CDATA[Barney Chen]]></dc:creator>
		<pubDate>Wed, 06 Jan 2016 00:30:31 +0000</pubDate>
				<category><![CDATA[每日一篇]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[主機管理]]></category>
		<category><![CDATA[資訊安全]]></category>
		<guid isPermaLink="false">https://wordpress.lokidea.com/?p=431</guid>

					<description><![CDATA[用Git也會有資安問題?? 我也是某天收到了封信件才知道這件事情 百度雲觀測寄了一封信來 內容如下： 概述 名 &#8230; <a href="https://wordpress.lokidea.com/431/%e4%bd%bf%e7%94%a8git%e7%9a%84%e8%b3%87%e5%ae%89%e5%95%8f%e9%a1%8c%e3%80%906-366%e3%80%91/" class="more-link">閱讀全文 <span class="screen-reader-text">使用Git的資安問題【6/366】</span></a>]]></description>
										<content:encoded><![CDATA[<p>用Git也會有資安問題??<br />
我也是某天收到了封信件才知道這件事情<br />
<a href="http://ce.baidu.com/" target="_blank" rel="noopener noreferrer">百度雲觀測</a>寄了一封信來<br />
內容如下：</p>
<table class=" alignleft" style="height: 78px;" border="0" width="595" cellspacing="0" cellpadding="0" align="left">
<thead>
<tr align="left">
<th>概述</th>
<th>名称</th>
<th>等级</th>
<th>来源</th>
</tr>
</thead>
<tbody>
<tr align="left">
<td>敏感信息泄露</td>
<td>git文件敏感信息泄露</td>
<td>低</td>
<td>安全漏洞</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p style="text-align: left;">看到就想到，原來這也是一個重要的資訊安全問題<br />
主機底下的資料夾，其實不能隨意開放<br />
不需要的資料夾就不能給予外部存取<br />
PS:但是百度也太晚通知我，我猜它們也是最近才加入這部分的檢查</p>
<p style="text-align: left;"><span id="more-431"></span></p>
<p style="text-align: left;">重點就是.git/這個資料夾<br />
當你用git管理版本，在目錄底下 git init 以後<br />
.git/ 裡面就是整個版本控制的全部內容<br />
所以應該要隱藏起來<br />
至於怎麼隱藏的方法其實很多</p>
<ol>
<li style="text-align: left;">修改.htaccess檔案</li>
<li style="text-align: left;">修改http主機的路由設定</li>
</ol>
<p>這兩個方法都可以讓外部無法存取.git/這個資料夾<br />
因為我自己用Apache所以也只能用這兩種<br />
PS:希望未來有機會補上IIS跟nginx的做法</p>
<h6>修改.htaccess檔案</h6>
<p>加入一行</p>
<blockquote>
<pre><code>RedirectMatch 404 /\.git</code></pre>
</blockquote>
<p>資料參考：<a href="http://stackoverflow.com/questions/6142437/make-git-directory-web-inaccessible" target="_blank" rel="noopener noreferrer">.htaccess &#8211; Make .git directory web inaccessible &#8211; Stack Overflow</a></p>
<h6>修改http主機的路由設定</h6>
<p>因為使用Apache &#8211; Virtual Host 進行分配網域<br />
所以在設定apache的 *.conf 裡面加入一段</p>
<blockquote>
<div class="post-text">
<pre><code>&lt;Directorymatch &quot;^/.*/\.git/&quot;&gt;
Order deny,allow
Deny from all
&lt;/Directorymatch&gt;
</code></pre>
</div>
</blockquote>
<p>然後記得要 service apache2 reload<br />
資料參考：<a href="http://serverfault.com/questions/128069/how-do-i-prevent-apache-from-serving-the-git-directory" target="_blank" rel="noopener noreferrer">How do I prevent apache from serving the .git directory? &#8211; Server Fault</a><br />
其他連結參考：<br />
<a href="http://stackoverflow.com/questions/398008/deny-access-to-svn-folders-on-apache" target="_blank" rel="noopener noreferrer">Deny access to .svn folders on Apache &#8211; Stack Overflow</a><br />
也歡迎大家補充其他http主機的做法</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wordpress.lokidea.com/431/%e4%bd%bf%e7%94%a8git%e7%9a%84%e8%b3%87%e5%ae%89%e5%95%8f%e9%a1%8c%e3%80%906-366%e3%80%91/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
