<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>ghe 归档 - Tinyfool的个人网站</title>
	<atom:link href="https://codechina.org/tag/ghe/feed/" rel="self" type="application/rss+xml" />
	<link>https://codechina.org/tag/ghe/</link>
	<description></description>
	<lastBuildDate>Thu, 23 Jul 2020 02:56:28 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Github 企业版如何限制访问IP？</title>
		<link>https://codechina.org/2020/07/1722/</link>
					<comments>https://codechina.org/2020/07/1722/#respond</comments>
		
		<dc:creator><![CDATA[tinyfool]]></dc:creator>
		<pubDate>Thu, 23 Jul 2020 02:51:31 +0000</pubDate>
				<category><![CDATA[Github]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ghe]]></category>
		<category><![CDATA[ufw]]></category>
		<guid isPermaLink="false">https://codechina.org/?p=1722</guid>

					<description><![CDATA[<p>有很多公司的 Github 企业版运行在完全的内网，有些公司的 Github 企业版运行在公网上。不管内网还是 [&#8230;]</p>
<p><a href="https://codechina.org/2020/07/1722/">Github 企业版如何限制访问IP？</a>最先出现在<a href="https://codechina.org">Tinyfool的个人网站</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>有很多公司的 Github 企业版运行在完全的内网，有些公司的 Github 企业版运行在公网上。不管内网还是公网，从企业信息安全的角度上公司、安全人员或者管理人员总是希望给服务器加上 IP 访问控制。</p>



<p>我之前研究了下，原来 Github 企业版已经内置了 UFW 防火墙软件。其实，我们只需要简单的利用 UFW 防火墙增加一些访问规则就可以轻松的给服务器增加 IP 访问控制了。</p>



<span id="more-1722"></span>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><span style="color: inherit; font-size: inherit;">UFW 的全称是 Uncomplicated Firewall，其实就是“不复杂的防火墙”，从名字就知道，UFW 的设计就是为了简单易用的，我大概玩了玩，感觉比 iptables 确实简单亲民多了。从Ubuntu 8.04 LTS 以后，UFW 都是默认的防火墙选项了。</span></p></blockquote>



<p>首先，<code>ssh -p 122 admin@yourip</code> 连接到你的 Github 企业版终端后台。然后，执行：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo ufw status</code></pre>



<p>输出结果大概为如下：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">Status: active

To                         Action      From
--                         ------      ----
ghe-1194                   ALLOW       Anywhere                  
ghe-122                    ALLOW       Anywhere                  
ghe-161                    ALLOW       Anywhere                  
ghe-22                     ALLOW       Anywhere                  
ghe-25                     ALLOW       Anywhere                  
ghe-443                    ALLOW       Anywhere                  
ghe-80                     ALLOW       Anywhere                  
ghe-8080                   ALLOW       Anywhere                  
ghe-8443                   ALLOW       Anywhere                  
ghe-9418                   ALLOW       Anywhere                  
ghe-1194 (v6)              ALLOW       Anywhere (v6)             
ghe-122 (v6)               ALLOW       Anywhere (v6)             
ghe-161 (v6)               ALLOW       Anywhere (v6)             
ghe-22 (v6)                ALLOW       Anywhere (v6)             
ghe-25 (v6)                ALLOW       Anywhere (v6)             
ghe-443 (v6)               ALLOW       Anywhere (v6)             
ghe-80 (v6)                ALLOW       Anywhere (v6)             
ghe-8080 (v6)              ALLOW       Anywhere (v6)             
ghe-8443 (v6)              ALLOW       Anywhere (v6)             
ghe-9418 (v6)              ALLOW       Anywhere (v6)             
</code></pre>



<p>这些就是当年 Github 企业版内置的标准规则，你大概对照 <a href="https://docs.github.com/cn/enterprise/2.21/admin/installation/network-ports">Github 企业版端口文档</a>，就大概知道这些端口是干啥的。</p>



<p>默认情况下不建议修改这些设置。但是如果你希望限制某些 IP 才能访问 Github 企业版的https端，那么你可以这样把某个 IP 例如 101.83.88.134 加入你的白名单IP：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo ufw allow from 101.83.88.134 to any port 443</code></pre>



<p>系统会返回：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">Rule added</code></pre>



<p>这代表规则已经添加成功，你再执行 <code>sudo ufw status</code>，返回就会多一行：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">443                        ALLOW       101.80.99.250             
</code></pre>



<p>然后，当你把全部要加入白名单的 IP 都加入以后，你还需要把原有的默认任何 IP 都可以访问 443 的规则删除，也就是 <code>ghe-443 ALLOW Anywhere</code> 那一行。</p>



<p>怎么删除呢？首先你要得到规则号码，这时候你可以用 </p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo ufw status numbered</code></pre>



<p>这样你就会发现，ghe-443 前面出现了一个编号，如下：</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">[ 6] ghe-443                    ALLOW IN    Anywhere                 </code></pre>



<p>然后你执行</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo ufw delete 6</code></pre>



<p>这样默认任何 IP 可以访问 443 的规则就被删除了，这个时候你的服务器的 443 端口也就是 https 协议，只有你指定的 IP 可以访问了。</p>



<p>如果你想限制什么 IP 能访问服务器的终端后台，操作方法类似，只不过端口是 122。但是切记不要误操作，以免让自己无法登录终端后台进行维护了。</p>



<p>注：这个规则在 Github 企业版服务器升级的时候，会被抹除，所以，如果你指定好了相应的规则，你可以把它写成脚本，每次升级后再执行一次即可。</p>
<p><a href="https://codechina.org/2020/07/1722/">Github 企业版如何限制访问IP？</a>最先出现在<a href="https://codechina.org">Tinyfool的个人网站</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codechina.org/2020/07/1722/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<media:content url="https://codechina.org/wp-content/uploads/2020/06/1_zZ_-f5n45vnjrQt2G3FIyg-1024x340.png" medium="image" />
	</item>
		<item>
		<title>Github Desktop如何添加使用自签证书的Github企业版账号</title>
		<link>https://codechina.org/2020/06/1673/</link>
					<comments>https://codechina.org/2020/06/1673/#respond</comments>
		
		<dc:creator><![CDATA[tinyfool]]></dc:creator>
		<pubDate>Tue, 16 Jun 2020 03:32:04 +0000</pubDate>
				<category><![CDATA[Github]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ghe]]></category>
		<category><![CDATA[github]]></category>
		<guid isPermaLink="false">https://codechina.org/?p=1673</guid>

					<description><![CDATA[<p>Github Desktop 是 Github 自己出品的 Git 和 Github 客户端，特别是针对 Gi [&#8230;]</p>
<p><a href="https://codechina.org/2020/06/1673/">Github Desktop如何添加使用自签证书的Github企业版账号</a>最先出现在<a href="https://codechina.org">Tinyfool的个人网站</a>。</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-a611da6a-4208-4c7a-86bc-0a5faee180c9      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							目录						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#自签证书会带来的问题" class="uagb-toc-link__trigger">自签证书会带来的问题</a><li class="uagb-toc__list"><a href="#解决方法" class="uagb-toc-link__trigger">解决方法</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#第一步在欢迎页选择-skip-this-step-跳过欢迎页" class="uagb-toc-link__trigger">第一步，在欢迎页选择 skip this step 跳过欢迎页</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#第二步正常设置你的-git-信息" class="uagb-toc-link__trigger">第二步，正常设置你的 Git 信息</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#第三步填写服务器地址" class="uagb-toc-link__trigger">第三步，填写服务器地址</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#首先在菜单里面选择-preferences" class="uagb-toc-link__trigger">首先，在菜单里面选择 Preferences:</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#在弹出的界面选择-accounts然后点击-github-enterprise-server-旁边的-sign-in-按钮" class="uagb-toc-link__trigger">在弹出的界面选择 Accounts，然后点击 Github Enterprise Server 旁边的 Sign In 按钮。</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#然后填写你的-github-企业版服务器地址" class="uagb-toc-link__trigger">然后填写你的 Github 企业版服务器地址：</a></li></ul><li class="uagb-toc__list"><a href="#第四步信任证书" class="uagb-toc-link__trigger">第四步，信任证书。</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#请选择查看证书-view-certificate" class="uagb-toc-link__trigger">请选择查看证书 View Certificate</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#然后在弹出的证书介绍页面选择显示证书" class="uagb-toc-link__trigger">然后，在弹出的证书介绍页面选择显示证书</a></li></ul><li class="uagb-toc__list"><a href="#第五步登录你的账号和密码稍事等待设置就完成了" class="uagb-toc-link__trigger">第五步，登录你的账号和密码，稍事等待设置就完成了。</a></ul></ol>					</div>
									</div>
				</div>
			


<p>Github Desktop 是 Github 自己出品的 Git 和 Github 客户端，特别是针对 Github 的各种特定功能都有支持，所以现在很流行也被广泛的使用。</p>



<h3 class="wp-block-heading">自签证书会带来的问题</h3>



<p>有些企业的 Github 企业版因为种种原因没有申请正式的证书，或者是在POC，内部部署测试期间，没有申请证书。那么有些时候，比如刚刚下载 Github Desktop 就会在默认的欢迎页面遇到困难。例如下图：</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="405" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-1024x405.png" alt="" class="wp-image-1674" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-1024x405.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-300x119.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-768x304.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-1536x608.png 1536w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32-1200x475.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午11.00.32.png 1752w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">解决方法</h3>



<h4 class="wp-block-heading">第一步，在欢迎页选择 <strong>skip this step</strong> 跳过欢迎页</h4>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="450" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-1024x450.png" alt="" class="wp-image-1675" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-1024x450.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-300x132.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-768x338.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-1536x676.png 1536w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19-1200x528.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.19.png 1885w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">第二步，正常设置你的 Git 信息</h4>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="435" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-1024x435.png" alt="" class="wp-image-1676" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-1024x435.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-300x128.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-768x326.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-1536x653.png 1536w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38-1200x510.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.41.38.png 1894w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>这个信息是提供在提交记录里面你的个人信息的。填写 Name 和 Email 即可。</p>



<h4 class="wp-block-heading">第三步，填写服务器地址</h4>



<h5 class="wp-block-heading">首先，在菜单里面选择 Preferences:</h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="800" height="485" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.23.png" alt="" class="wp-image-1677" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.23.png 800w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.23-300x182.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.23-768x466.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></figure>



<h5 class="wp-block-heading">在弹出的界面选择 Accounts，然后点击 Github Enterprise Server 旁边的 Sign In 按钮。</h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="494" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42-1024x494.png" alt="" class="wp-image-1678" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42-1024x494.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42-300x145.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42-768x370.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42-1200x578.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.42.42.png 1220w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h5 class="wp-block-heading">然后填写你的 Github 企业版服务器地址：</h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="828" height="446" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.12.png" alt="" class="wp-image-1679" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.12.png 828w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.12-300x162.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.12-768x414.png 768w" sizes="auto, (max-width: 828px) 100vw, 828px" /></figure>



<h4 class="wp-block-heading">第四步，信任证书。</h4>



<p>接下来会提示你这个服务器的证书是自签证书。提示也介绍了，你在试用 Github 企业版服务器的时候，自签证书是很普遍的。</p>



<h5 class="wp-block-heading">请选择查看证书 View Certificate</h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="547" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49-1024x547.png" alt="" class="wp-image-1680" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49-1024x547.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49-300x160.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49-768x410.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49-1200x640.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.43.49.png 1216w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h5 class="wp-block-heading">然后，在弹出的证书介绍页面选择显示证书 </h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="371" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03-1024x371.png" alt="" class="wp-image-1681" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03-1024x371.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03-300x109.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03-768x278.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03-1200x435.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.03.png 1236w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>然后选择始终信任即可</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="700" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36-1024x700.png" alt="" class="wp-image-1682" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36-1024x700.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36-300x205.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36-768x525.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36-1200x820.png 1200w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.44.36.png 1282w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">第五步，登录你的账号和密码，稍事等待设置就完成了。</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="906" height="770" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.47.09.png" alt="" class="wp-image-1683" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.47.09.png 906w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.47.09-300x255.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.47.09-768x653.png 768w" sizes="auto, (max-width: 906px) 100vw, 906px" /></figure>



<p>完成设置后，你就可以点击 Clone a Repository 把一个 repo 克隆到本地进行操作了。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="970" src="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.48.02-1024x970.png" alt="" class="wp-image-1684" srcset="https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.48.02-1024x970.png 1024w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.48.02-300x284.png 300w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.48.02-768x727.png 768w, https://codechina.org/wp-content/uploads/2020/06/截屏2020-06-16上午10.48.02.png 1098w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
<p><a href="https://codechina.org/2020/06/1673/">Github Desktop如何添加使用自签证书的Github企业版账号</a>最先出现在<a href="https://codechina.org">Tinyfool的个人网站</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codechina.org/2020/06/1673/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			<media:content url="https://codechina.org/wp-content/uploads/2020/06/1_zZ_-f5n45vnjrQt2G3FIyg-1024x340.png" medium="image" />
	</item>
	</channel>
</rss>
