From 902a37fa0a02773a0ec37beaf91c175768b6269d Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 11:50:48 +0800 Subject: [PATCH 001/485] Update 20170703 Brewing beer with Linux python and raspberry pi.md --- .../20170703 Brewing beer with Linux python and raspberry pi.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md index bea84931c7..d9bd699d63 100644 --- a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,3 +1,4 @@ +hwlife is translating Brewing beer with Linux, Python, and Raspberry Pi ============================================================ From 0b2e1bb4fe78d15fa55de3736479f0ba052824c6 Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 11:51:08 +0800 Subject: [PATCH 002/485] Update 20170703 Brewing beer with Linux python and raspberry pi.md --- .../20170703 Brewing beer with Linux python and raspberry pi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md index d9bd699d63..f96cf25179 100644 --- a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,4 +1,4 @@ -hwlife is translating +hwlife is translating Brewing beer with Linux, Python, and Raspberry Pi ============================================================ From e3accc39ef8b3b9c5a9f7d3e4218b97a3a54293f Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 11:51:41 +0800 Subject: [PATCH 003/485] Update 20170703 Brewing beer with Linux python and raspberry pi.md hwlife is translating --- .../20170703 Brewing beer with Linux python and raspberry pi.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md index f96cf25179..bea84931c7 100644 --- a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,4 +1,3 @@ -hwlife is translating Brewing beer with Linux, Python, and Raspberry Pi ============================================================ From 33fbce6d9fc31a96c69df9e21247ee604065d24f Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 11:59:30 +0800 Subject: [PATCH 004/485] Create 20170703 Brewing beer with Linux python and raspberry pi.md --- ...beer with Linux python and raspberry pi.md | 192 ++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md diff --git a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md new file mode 100644 index 0000000000..bea84931c7 --- /dev/null +++ b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -0,0 +1,192 @@ +Brewing beer with Linux, Python, and Raspberry Pi +============================================================ + +### A handy how-to for building a homemade homebrew setup with Python and the Raspberry Pi. + + +![Brewing beer with Linux, Python, and Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/beer-drink-sample-sampler.png?itok=20jJLB8V "Brewing beer with Linux, Python, and Raspberry Pi") +Image by :  + +[Quinn Dombrowski][21]. Modified by Opensource.com. [CC BY-SA 4.0][22]. + +I started brewing my own beer more than 10 years ago. Like most homebrewers, I started in my kitchen making extract-based brews. This required the least equipment and still resulted in really tasty beer. Eventually I stepped up to all-grain brewing using a big cooler for my mash tun. For several years I was brewing 5 gallons at a time, but brewing 10 gallons takes the same amount of time and effort (and only requires slightly larger equipment), so a few years ago I stepped it up. After moving up to 10 gallons, I stumbled across [StrangeBrew Elsinore][23] and realized what I  _really_  needed to do was convert my whole system to be all-electric, and run it with a [Raspberry Pi][24]. + +There is a ton of great information available for building your own all-electric homebrew system, and most brewers start out at [TheElectricBrewery.com][25]. Just putting together the control panel can get pretty complicated, although the simplest approach is outlined well there. Of course you can also take [a less expensive approach][26] and still end up with the same result—a boil kettle and hot liquor tank powered by heating elements and managed by a PID controller. I think that's a little too boring though (and it also means you don't get neat graphs of your brew process). + +More on Raspberry Pi + +* [Our latest on Raspberry Pi][1] + +* [What is Raspberry Pi?][2] + +* [Getting started with Raspberry Pi][3] + +* [Send us your Raspberry Pi projects and tutorials][4] + +### Hardware supplies + +Before I talked myself out of the project, I decided to start buying parts. My basic design was a Hot Liquor Tank (HLT) and boil kettle with 5500w heating elements in them, plus a mash tun with a false bottom. I would use a pump to recirculate the mash through a 50' stainless coil in the HLT (a ["heat exchanger recirculating mash system", known as HERMS][27]). I would need a second pump to circulate the water in the HLT, and to help with transferring water to the mash tun. All of the electrical components would be controlled with a Raspberry Pi. + +Building my electric brew system and automating as much of it as possible meant I was going to need the following: + +* HLT with a 5500w electric heating element + +* HERMS coil (50' 1/2" stainless steel) in the HLT + +* boil kettle with a 5500w electric heating element + +* multiple solid-state relays to switch the heaters on and off + +* 2 high-temp food-grade pumps + +* relays for switching the pumps on and off + +* fittings and high-temp silicon tubing + +* stainless ball valves + +* 1-wire temperature probes + +* lots of wire + +* electrical box to hold everything + +### [aedo-f1.png][11] + +![Brew system](https://opensource.com/sites/default/files/aedo-f1.png "Brew system") + +Brew system (photo by Christopher Aedo. [CC BY-SA 4.0)][5] + +The details of building out the electrical side of the system are really well covered by [The Electric Brewery][28], so I won't repeat their detailed information. You can read through and follow their suggestions while planning to replace the PID controllers with a Raspberry Pi. + +One important thing to note is the solid-state relay (SSR) signal voltage. Many tutorials suggest using SSRs that need a 12-volt signal to close the circuit. The Raspberry Pi GPIO pins will only output 3v, however. Be sure to purchase relays that will trigger on 3 volts. + +### [aedo-f2.png][12] + +![Inkbird SSR](https://opensource.com/sites/default/files/aedo-f2.png "Inkbird SSR") + +Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6] + +To run your brew system, your Pi must do two key things: sense temperature from a few different places, and turn relays on and off to control the heating elements. The Raspberry Pi easily is able to handle these tasks. + +There are a few different ways to connect temp sensors to a Pi, but I've found the most convenient approach is to use the [1-Wire bus][29]. This allows for multiple sensors to share the same wire (actually three wires), which makes it a convenient way to instrument multiple components in your brew system. If you look for waterproof DS18B20 temperature sensors online, you'll find lots of options available. I used [Hilitchi DS18B20 Waterproof Temperature Sensors][30] for my project. + +To control the heating elements, the Raspberry Pi includes several General Purpose IO (GPIO) pins that are software addressable. This allows you to send 3.3v to a relay by simply putting a **1** or a **0** in a file. The  _Raspberry Pi—Driving a Relay using GPIO_  tutorial was the most helpful for me when I was first learning how all this worked. The GPIO controls multiple solid-state relays, turning on and off the heating elements as directed by the brewing software. + +I first started working on the box to hold all the components. Because this would all be on a rolling cart, I wanted it to be relatively portable rather than permanently mounted. If I had a spot (for example, inside a garage, utility room, or basement), I would have used a larger electrical box mounted on the wall. Instead I found a decent-size [waterproof project box][31] that I expected I could shoehorn everything into. In the end, it turned out to be a little bit of a tight fit, but it worked out. In the bottom left corner is the Pi with a breakout board for connecting the GPIO to the 1-Wire temperature probes and the [solid state relays][32]. + +To keep the 240v SSRs cool, I cut holes in the case and stacked [copper shims][33] with CPU cooling grease between them and heat sinks mounted on the outside of the box. It worked out well and there haven't been any cooling issues inside the box. On the cover I put two switches for 120v outlets, plus two 240v LEDs to show which heating element was energized. I used dryer plugs and outlets for all connections so disconnecting a kettle from everything is easy. Everything worked right on the first try, too. (Sketching a wiring diagram first definitely pays off.) + +The pictures are from the "proof-of-concept" version—the final production system should have two more SSRs so that both legs of the 240v circuit would be switched. The other thing I would like to switch via software is the pumps. Right now they're controlled via physical switches on the front of the box, but they could easily be controlled with relays. + +### [aedo-f3.png][13] + +![Control box](https://opensource.com/sites/default/files/aedo-f3.png "Control box") + +Control box (photo by Christopher Aedo. [CC BY-SA 4.0)][7] + +The only other thing I needed that was a little tricky to find was a compression fitting for the temperature probes. The probes were mounted in T fittings before the valve on the lowest bulkhead in both the HLT and the mash tun. As long as the liquid is flowing past the temp sensor, it's going to be accurate. I thought about adding a thermowell into the kettles as well, but realized that's not going to be useful for me based on my brewing process. Anyway, I purchased [1/4" compression fittings][34] and they worked out perfectly. + +### Software + +Once the hardware was sorted out, I had time to play with the software. I ran the latest [Raspbian distribution][35] on the Pi; nothing special was required on the operating-system side. + +I started with [Strangebrew Elsinore][36] brewing software, which I had discovered when a friend asked whether I had heard of [Hosehead][37], a Raspberry Pi-based brewing controller. I thought Hosehead looked great, but rather than buying a brewing controller, I wanted the challenge of building my own. + +Setting up Strangebrew Elsinore was straightforward—the [documentation][38] was thorough and I did not encounter any problems. Even though Strangebrew Elsinore was working fine, Java seemed to be taxing my first-generation Pi sometimes, and it crashed on me more than once. I also was sad to see development stall and there did not seem to be a big community of additional contributors (although there were—and still are—plenty of people using it). + +### CraftBeerPi + +Then I stumbled across [CraftBeerPI][39], which is written in Python and supported by a development community of active contributors. The original author (and current maintainer) Manuel Fritsch is great about handling contributions and giving feedback on issues that folks open. Cloning [the repo][40] and getting started only took me a few minutes. The README also has a good example of connecting DS1820 temp sensors, along with notes on interfacing hardware to a Pi or a [C.H.I.P. computer][41]. + +On startup, CraftBeerPi walks users through a configuration process that discovers the temperature probes available and lets you specify which GPIO pins are managing which pieces of equipment. + +### [aedo-f4.png][14] + +![CraftBeerPi](https://opensource.com/sites/default/files/images/life/aedo-f4.png "CraftBeerPi") + +CraftBeerPi (photo by Christopher Aedo. [CC BY-SA 4.0)][8] + +Running a brew with this system is easy. I can count on it holding temperatures reliably, and I can input steps for a multi-temp step mash. Using CraftBeerPi has made my brew days a little bit boring, but I'm happy to trade off the "excitement" of traditional manually managed propane burners for the efficiency and consistency of this system. + +CraftBeerPI's user-friendliness inspired me to set up another controller to run a "fermentation chamber." In my case, that was a second-hand refrigerator I found for US$ 50 plus a $25 heater) on the inside. CraftBeerPI easily can control the cooling and heating elements, and you can set up multiple temperature steps. For instance, this graph shows the fermentation temperatures for a session IPA I made recently. The fermentation chamber held the fermenting wort at 67F for four days, then ramped up one degree every 12 hours until it was at 72F. That temp was held for a two-day diacetyl rest. After that it was set to drop down to 65F for five days, during which time I "dry hopped" the beer. Finally, the beer was cold-crashed down to 38F. CraftBeerPI made adding each step and letting the software manage the fermentation easy. + +### [aedo-f5.png][15] + +![SIPA fermentation profile](https://opensource.com/sites/default/files/aedo-f5.png "SIPA fermentation profile") + +SIPA fermentation profile (photo by Christopher Aedo. [CC BY-SA 4.0)][9] + +I have also been experimenting with the [TILT hydrometer][42] to monitor the gravity of the fermenting beer via a Bluetooth-connected floating sensor. There are integration plans for this to get it working with CraftBeerPI, but for now it logs the gravity to a Google spreadsheet. Once this hydrometer can talk to the fermentation controller, setting automated fermentation profiles that take action directly based on the yeast activity would be easy—rather than banking on primary fermentation completing in four days, you can set the temperature ramp to kick off after the gravity is stable for 24 hours. + +As with any project like this, imaging and planning improvements and additional components is easy. Still, I'm happy with where things stand today. I've brewed a lot of beer with this setup and am hitting the expected mash efficiency every time, and the beer has been consistently tasty. My most important customer—me!—is pleased with what I've been putting on tap in my kitchen. + +### [aedo-f6.png][16] + +![Homebrew on tap](https://opensource.com/sites/default/files/aedo-f6.png "Homebrew on tap") + +Homebrew on tap (photo by Christopher Aedo. [CC BY-SA 4.0)][10] + + _This article is based on Christopher's OpenWest talk, [Brewing Beer with Linux, Python and a RaspberryPi][18]. [OpenWest][19] will be held July 12-15, 2017 in Salt Lake City, Utah._ + +-------------------------------------------------------------------------------- + +作者简介: + +Christopher Aedo - Christopher Aedo has been working with and contributing to open source software since his college days. Most recently he can be found leading an amazing team of upstream developers at IBM who are also developer advocates. When he’s not at work or speaking at a conference, he’s probably using a RaspberryPi to brew and ferment a tasty homebrew in Portland OR. + + +via: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi + +作者:[ Christopher Aedo][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/docaedo +[1]:https://opensource.com/tags/raspberry-pi?src=raspberry_pi_resource_menu1 +[2]:https://opensource.com/resources/what-raspberry-pi?src=raspberry_pi_resource_menu2 +[3]:https://opensource.com/article/16/12/getting-started-raspberry-pi?src=raspberry_pi_resource_menu3 +[4]:https://opensource.com/article/17/2/raspberry-pi-submit-your-article?src=raspberry_pi_resource_menu4 +[5]:https://creativecommons.org/licenses/by-sa/4.0/ +[6]:https://creativecommons.org/licenses/by-sa/4.0/ +[7]:https://creativecommons.org/licenses/by-sa/4.0/ +[8]:https://creativecommons.org/licenses/by-sa/4.0/ +[9]:https://creativecommons.org/licenses/by-sa/4.0/ +[10]:https://creativecommons.org/licenses/by-sa/4.0/ +[11]:https://opensource.com/file/358661 +[12]:https://opensource.com/file/358666 +[13]:https://opensource.com/file/358676 +[14]:https://opensource.com/file/359061 +[15]:https://opensource.com/file/358681 +[16]:https://opensource.com/file/359071 +[17]:https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi?rate=fbKzT1V9gqGsmNCTuQIashC1xaHT5P_2LUaeTn6Kz1Y +[18]:https://www.openwest.org/custom/description.php?id=139 +[19]:https://www.openwest.org/ +[20]:https://opensource.com/user/145976/feed +[21]:https://www.flickr.com/photos/quinndombrowski/ +[22]:https://creativecommons.org/licenses/by-sa/4.0/ +[23]:https://github.com/DougEdey/SB_Elsinore_Server +[24]:https://opensource.com/tags/raspberry-pi +[25]:http://www.theelectricbrewery.com/ +[26]:http://www.instructables.com/id/Electric-Brewery-Control-Panel-on-the-Cheap/ +[27]:https://byo.com/hops/item/1325-rims-and-herms-brewing-advanced-homebrewing +[28]:http://theelectricbrewery.com/ +[29]:https://en.wikipedia.org/wiki/1-Wire +[30]:https://smile.amazon.com/gp/product/B018KFX5X0/ +[31]:http://amzn.to/2hupFCr +[32]:http://amzn.to/2hL8JDS +[33]:http://amzn.to/2i4DYwy +[34]:https://www.brewershardware.com/CF1412.html +[35]:https://www.raspberrypi.org/downloads/raspbian/ +[36]:https://github.com/DougEdey/SB_Elsinore_Server +[37]:https://brewtronix.com/ +[38]:http://dougedey.github.io/SB_Elsinore_Server/ +[39]:http://www.craftbeerpi.com/ +[40]:https://github.com/manuel83/craftbeerpi +[41]:https://www.nextthing.co/pages/chip +[42]:https://tilthydrometer.com/ +[43]:https://opensource.com/users/docaedo +[44]:https://opensource.com/users/docaedo +[45]:https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi#comments From 1922af107e6067d17abec5279abe5ad1513a2a2a Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 12:02:08 +0800 Subject: [PATCH 005/485] Update 20170703 Brewing beer with Linux python and raspberry pi.md --- .../20170703 Brewing beer with Linux python and raspberry pi.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md index bea84931c7..d9bd699d63 100644 --- a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,3 +1,4 @@ +hwlife is translating Brewing beer with Linux, Python, and Raspberry Pi ============================================================ From c9dc680fe71599bf4483defad562a15c209a0ec8 Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 14:36:43 +0800 Subject: [PATCH 006/485] Update 20170703 Brewing beer with Linux python and raspberry pi.md --- ...beer with Linux python and raspberry pi.md | 70 ++++++++++--------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md index bea84931c7..cea388ac23 100644 --- a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,7 +1,7 @@ -Brewing beer with Linux, Python, and Raspberry Pi +用Linux,Python和树莓派酿制啤酒 ============================================================ -### A handy how-to for building a homemade homebrew setup with Python and the Raspberry Pi. +### 怎样在家用python和树莓派搭建一个家用便携的自制酿啤酒装置 ![Brewing beer with Linux, Python, and Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/beer-drink-sample-sampler.png?itok=20jJLB8V "Brewing beer with Linux, Python, and Raspberry Pi") @@ -9,57 +9,59 @@ Image by :  [Quinn Dombrowski][21]. Modified by Opensource.com. [CC BY-SA 4.0][22]. -I started brewing my own beer more than 10 years ago. Like most homebrewers, I started in my kitchen making extract-based brews. This required the least equipment and still resulted in really tasty beer. Eventually I stepped up to all-grain brewing using a big cooler for my mash tun. For several years I was brewing 5 gallons at a time, but brewing 10 gallons takes the same amount of time and effort (and only requires slightly larger equipment), so a few years ago I stepped it up. After moving up to 10 gallons, I stumbled across [StrangeBrew Elsinore][23] and realized what I  _really_  needed to do was convert my whole system to be all-electric, and run it with a [Raspberry Pi][24]. +大约十年前我开始酿制自制啤酒,和许多自己酿酒的人一样,我开始在厨房制造提纯啤酒。这需要一些设备并且做出来后确实是好的啤酒,最终,我用一个大的贮藏罐放入了所有大麦作为我的麦芽浆桶。几年之后我曾酿制了5加仑啤酒,但是酿制10加仑时会花费同样的时间和效用(只是容器比之前大些),之前我是这么做的。容量提升到10加仑之后,我偶然发现并意识到我真正需要的是将整个酿酒过程转换成全电子化的,用树莓派来运行它。 -There is a ton of great information available for building your own all-electric homebrew system, and most brewers start out at [TheElectricBrewery.com][25]. Just putting together the control panel can get pretty complicated, although the simplest approach is outlined well there. Of course you can also take [a less expensive approach][26] and still end up with the same result—a boil kettle and hot liquor tank powered by heating elements and managed by a PID controller. I think that's a little too boring though (and it also means you don't get neat graphs of your brew process). +建造自己的家用电动化酿酒系统需要大量这方面的技术信息,许多学习酿酒的是在TheElectricBrewery.com这个网站起步的,只不过将那些控制版搭建在一起是十分复杂的,尽管最简单的办法在这个网站上总结的很好。当然你也能用一个小成本的方法并且依旧可以用相同的结果得到-用一个热水壶和热酒容器通过一个PID控制器来加热你的酿酒原料。但是我认为这有点太无聊(这也意味着你不能get到完成酿酒过程) -More on Raspberry Pi +关于树莓派更多信息 -* [Our latest on Raspberry Pi][1] +* [关于树莓派最新消息[1] -* [What is Raspberry Pi?][2] +* [树莓派是什么?][2] -* [Getting started with Raspberry Pi][3] +* [树莓派如何开始使用][3] -* [Send us your Raspberry Pi projects and tutorials][4] +* [发送给我们你的树莓派项目和教程][4] -### Hardware supplies +### 需要用到的硬件 -Before I talked myself out of the project, I decided to start buying parts. My basic design was a Hot Liquor Tank (HLT) and boil kettle with 5500w heating elements in them, plus a mash tun with a false bottom. I would use a pump to recirculate the mash through a 50' stainless coil in the HLT (a ["heat exchanger recirculating mash system", known as HERMS][27]). I would need a second pump to circulate the water in the HLT, and to help with transferring water to the mash tun. All of the electrical components would be controlled with a Raspberry Pi. +在我开始我得这个项目之前, 我决定开始买零件,我最基础的设计是一个可以将液体加热到5500w的热酒容器和开水壶,加一个活底的麦芽浆桶,我通过一个50的不锈钢线圈在热酒容器里让泵来再循环麦芽浆(a ["热量交换再循环麦芽浆系统, 也叫 HERMS][27]).同时我需要另一个泵来在热酒容器里循环水,并且把水传输到麦芽浆桶里,整个电子部件全部是用树莓派来控制的。 -Building my electric brew system and automating as much of it as possible meant I was going to need the following: -* HLT with a 5500w electric heating element +建立我得电子酿酒系统并且尽可能的自动化意味着我需要以下的东东: -* HERMS coil (50' 1/2" stainless steel) in the HLT -* boil kettle with a 5500w electric heating element +* 一个5500瓦的电子加热酒精容器 -* multiple solid-state relays to switch the heaters on and off +* 能够放入加热酒精容器里的一英尺(0.5英寸)长的不锈钢线圈(热量交换再循环麦芽浆系统) -* 2 high-temp food-grade pumps +* 一个5500瓦的电子加热水壶 -* relays for switching the pumps on and off +* 多个固态继电器加热开关 -* fittings and high-temp silicon tubing +* 2个高温食品级泵 -* stainless ball valves +* 泵的开关用继电器 -* 1-wire temperature probes +* 可拆除装置和一个硅管 -* lots of wire +* 不锈钢球阀 -* electrical box to hold everything +* 一个测量温度的探针 + +* 很多线 + +* 一个来容纳这些配件的电路盒子 ### [aedo-f1.png][11] ![Brew system](https://opensource.com/sites/default/files/aedo-f1.png "Brew system") -Brew system (photo by Christopher Aedo. [CC BY-SA 4.0)][5] +酿酒系统 (photo by Christopher Aedo. [CC BY-SA 4.0)][5] -The details of building out the electrical side of the system are really well covered by [The Electric Brewery][28], so I won't repeat their detailed information. You can read through and follow their suggestions while planning to replace the PID controllers with a Raspberry Pi. +建立酿酒系统的电气化方面的细节The Electric Brewery这个网站概括的很好,这里我不再重复,当你计划用树莓派代替这个PID控制器的话,你可以读以下的建议。 -One important thing to note is the solid-state relay (SSR) signal voltage. Many tutorials suggest using SSRs that need a 12-volt signal to close the circuit. The Raspberry Pi GPIO pins will only output 3v, however. Be sure to purchase relays that will trigger on 3 volts. +一个重要的事情需要注意,固态继电器信号电压,许多教程建议使用一个12伏的固态继电器来关闭电路,树莓派的GPIO针插口只支持输出电压3伏,然而,必须购买继电器将电压变为3伏。 ### [aedo-f2.png][12] @@ -67,23 +69,25 @@ One important thing to note is the solid-state relay (SSR) signal voltage. Many Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6] -To run your brew system, your Pi must do two key things: sense temperature from a few different places, and turn relays on and off to control the heating elements. The Raspberry Pi easily is able to handle these tasks. +要运行酿酒系统,你的树莓派必须做两个关键事情:来自不同位置的敏感温度,用继电器开关来控制加热元件,树莓派很容易来处理这些任务。 -There are a few different ways to connect temp sensors to a Pi, but I've found the most convenient approach is to use the [1-Wire bus][29]. This allows for multiple sensors to share the same wire (actually three wires), which makes it a convenient way to instrument multiple components in your brew system. If you look for waterproof DS18B20 temperature sensors online, you'll find lots of options available. I used [Hilitchi DS18B20 Waterproof Temperature Sensors][30] for my project. +这里有一些不同的方法来将温度传感器连到树莓派上,但是我找到了最方便的方法用单总线。这就可以让多个传感器分享相同的线路(实际上三根线),这三根线可以使酿酒系统的多个设备更方便的工作,如果你要从网上找一个DS18B20 防水的温度传感器,你将会找到更多的选择。我用的是日立DS18B20防水温度传感器。 -To control the heating elements, the Raspberry Pi includes several General Purpose IO (GPIO) pins that are software addressable. This allows you to send 3.3v to a relay by simply putting a **1** or a **0** in a file. The  _Raspberry Pi—Driving a Relay using GPIO_  tutorial was the most helpful for me when I was first learning how all this worked. The GPIO controls multiple solid-state relays, turning on and off the heating elements as directed by the brewing software. +要控制加热元件,树莓派包括几个用来软件寻址的总线扩展器(GPIO),它会通过在某个文件写入0或者1让你发送3.3v的电压到一个继电器,在我第一次了解树莓派是怎样工作的时候,这个用GPIO驱动继电器的树莓派教程对我来说是最有帮助的,总线控制器控制多个固态继电器,通过酿酒软件来直接控制加热元件的开关。 -I first started working on the box to hold all the components. Because this would all be on a rolling cart, I wanted it to be relatively portable rather than permanently mounted. If I had a spot (for example, inside a garage, utility room, or basement), I would have used a larger electrical box mounted on the wall. Instead I found a decent-size [waterproof project box][31] that I expected I could shoehorn everything into. In the end, it turned out to be a little bit of a tight fit, but it worked out. In the bottom left corner is the Pi with a breakout board for connecting the GPIO to the 1-Wire temperature probes and the [solid state relays][32]. +我第一次将所有部件放到这个电路盒子,因为这将成为一个滚动的小车,我要让他方便移动,而不是固定不动的,如果我有一个店(比如说在车库,工具房,或者地下室),我需要要用一个更大的电路盒挂到墙上,而现在我找到一个大小正好的防水工程盒子,能放进每件东西,最后它成为紧密的结合工具盒,并且能够工作。在左下角是和树莓派连接的为总线控制器到单总线温度探针和固态继电器的扩展板。 -To keep the 240v SSRs cool, I cut holes in the case and stacked [copper shims][33] with CPU cooling grease between them and heat sinks mounted on the outside of the box. It worked out well and there haven't been any cooling issues inside the box. On the cover I put two switches for 120v outlets, plus two 240v LEDs to show which heating element was energized. I used dryer plugs and outlets for all connections so disconnecting a kettle from everything is easy. Everything worked right on the first try, too. (Sketching a wiring diagram first definitely pays off.) +要保持240v的固态继电器温度不高,我在盒子上切了个洞,在盒子的外面用降温凝胶安装铜片散热片冷却cpu的温度。它工作的很好,盒子里没有温度上的问题了,在盒子盖上我放了两个开关为120v的插座,加两个240v的led来显示加热元件是否通电。我用干燥器的插座和插头很容易的开关电热水壶的连接。第一次尝试每件事情都弄好了。(决定第一次手画电路图.) + + +照片是从“概念”版的最终生产系统应该有两个固态继电器,以至于240v的电路两个针脚能够切换,另外我将通过软件来切换泵的开关,。现在他们通过盒子前面的物理开关控制,但是他们很容易用继电器控制。 -The pictures are from the "proof-of-concept" version—the final production system should have two more SSRs so that both legs of the 240v circuit would be switched. The other thing I would like to switch via software is the pumps. Right now they're controlled via physical switches on the front of the box, but they could easily be controlled with relays. ### [aedo-f3.png][13] ![Control box](https://opensource.com/sites/default/files/aedo-f3.png "Control box") -Control box (photo by Christopher Aedo. [CC BY-SA 4.0)][7] +控制盒子 (photo by Christopher Aedo. [CC BY-SA 4.0)][7] The only other thing I needed that was a little tricky to find was a compression fitting for the temperature probes. The probes were mounted in T fittings before the valve on the lowest bulkhead in both the HLT and the mash tun. As long as the liquid is flowing past the temp sensor, it's going to be accurate. I thought about adding a thermowell into the kettles as well, but realized that's not going to be useful for me based on my brewing process. Anyway, I purchased [1/4" compression fittings][34] and they worked out perfectly. From 50cf00f1a668cd25abce926d4b29795dc49e5935 Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 16:10:22 +0800 Subject: [PATCH 007/485] Rename 20170703 Brewing beer with Linux python and raspberry pi.md to Transleted20170703 Brewing beer with Linux python and raspberry pi.md Transletd by hwlife --- ...eer with Linux python and raspberry pi.md} | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) rename translated/tech/{20170703 Brewing beer with Linux python and raspberry pi.md => Transleted20170703 Brewing beer with Linux python and raspberry pi.md} (65%) diff --git a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/translated/tech/Transleted20170703 Brewing beer with Linux python and raspberry pi.md similarity index 65% rename from translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md rename to translated/tech/Transleted20170703 Brewing beer with Linux python and raspberry pi.md index cea388ac23..29a9613204 100644 --- a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/translated/tech/Transleted20170703 Brewing beer with Linux python and raspberry pi.md @@ -89,21 +89,22 @@ Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6] 控制盒子 (photo by Christopher Aedo. [CC BY-SA 4.0)][7] -The only other thing I needed that was a little tricky to find was a compression fitting for the temperature probes. The probes were mounted in T fittings before the valve on the lowest bulkhead in both the HLT and the mash tun. As long as the liquid is flowing past the temp sensor, it's going to be accurate. I thought about adding a thermowell into the kettles as well, but realized that's not going to be useful for me based on my brewing process. Anyway, I purchased [1/4" compression fittings][34] and they worked out perfectly. +另一个事情是我要为温度探针找一个微型压缩装置,这个探针以T字型装置在加热酒精容器和麦芽浆桶球形阀门的最底部,只要是液体流过温度传感器,温度是准确显示的。我考虑加一个套管到热水壶里,但是基于我的酿造工艺没有什么用。无论如何,我买四分之一英寸的压缩配件,他们是完美的。 -### Software +### 软件 -Once the hardware was sorted out, I had time to play with the software. I ran the latest [Raspbian distribution][35] on the Pi; nothing special was required on the operating-system side. +一旦硬件整理好,我有时间来处理软件,我在树莓派上跑了最新的发行版,操作系统方面没有什么特别的。 -I started with [Strangebrew Elsinore][36] brewing software, which I had discovered when a friend asked whether I had heard of [Hosehead][37], a Raspberry Pi-based brewing controller. I thought Hosehead looked great, but rather than buying a brewing controller, I wanted the challenge of building my own. +我开始使用Strangebrew Elsinore酿酒软件,当我的朋友问我是否我听说过[Hosehead],一个基于树莓派的酿酒控制器,那时我已经听说过这个软件了。我认为[Hosehead]很棒,但并不是要买一个酿酒控制器,贰拾我要挑战自己搭建我自己的一个。 + +设置Strangebrew Elsinore 这个软件是按照说明文档操作,没有遇到任何的问题。尽管Strangebrew Elsinore工作的很好,在一代树莓派上运行java有时是费力的,不止崩溃一次。我看到这个软件开发停顿也很伤心,因为他们没有几个看起来很大的贡献者的社区(尽管有很多人还在用它) -Setting up Strangebrew Elsinore was straightforward—the [documentation][38] was thorough and I did not encounter any problems. Even though Strangebrew Elsinore was working fine, Java seemed to be taxing my first-generation Pi sometimes, and it crashed on me more than once. I also was sad to see development stall and there did not seem to be a big community of additional contributors (although there were—and still are—plenty of people using it). ### CraftBeerPi -Then I stumbled across [CraftBeerPI][39], which is written in Python and supported by a development community of active contributors. The original author (and current maintainer) Manuel Fritsch is great about handling contributions and giving feedback on issues that folks open. Cloning [the repo][40] and getting started only took me a few minutes. The README also has a good example of connecting DS1820 temp sensors, along with notes on interfacing hardware to a Pi or a [C.H.I.P. computer][41]. +之后我偶然遇到了一个用Python写的支持活跃的贡献者的开发社区的CraftbeerPI,应该叫手工啤酒派吧。原作者和当前维护者Manuel Fritsch在做贡献和反馈问题是友好的。克隆这个仓库然后开始花了我一些时间。README文档也是一个连接DS1820温度传感器的好例子,同时注意关于硬件接口到树莓派或者芯片电脑。 -On startup, CraftBeerPi walks users through a configuration process that discovers the temperature probes available and lets you specify which GPIO pins are managing which pieces of equipment. +在启动的时候,CraftbeerPI引导用户通过一个设置过程来发现温度探针是否可用,并且让你用GPIO总线控制器来管理树莓派上的特定设备部件 ### [aedo-f4.png][14] @@ -111,33 +112,34 @@ On startup, CraftBeerPi walks users through a configuration process that discove CraftBeerPi (photo by Christopher Aedo. [CC BY-SA 4.0)][8] -Running a brew with this system is easy. I can count on it holding temperatures reliably, and I can input steps for a multi-temp step mash. Using CraftBeerPi has made my brew days a little bit boring, but I'm happy to trade off the "excitement" of traditional manually managed propane burners for the efficiency and consistency of this system. +运行自制酿酒系统是容易的,我能够依靠它掌握可靠的温度,我能输入多个温度段来控制麦芽浆温度,用CraftbeerPi酿酒的日子有一点点累,但是传统手工管理丙烷燃烧器为系统的有效性和持续性我还是很高兴的。 -CraftBeerPI's user-friendliness inspired me to set up another controller to run a "fermentation chamber." In my case, that was a second-hand refrigerator I found for US$ 50 plus a $25 heater) on the inside. CraftBeerPI easily can control the cooling and heating elements, and you can set up multiple temperature steps. For instance, this graph shows the fermentation temperatures for a session IPA I made recently. The fermentation chamber held the fermenting wort at 67F for four days, then ramped up one degree every 12 hours until it was at 72F. That temp was held for a two-day diacetyl rest. After that it was set to drop down to 65F for five days, during which time I "dry hopped" the beer. Finally, the beer was cold-crashed down to 38F. CraftBeerPI made adding each step and letting the software manage the fermentation easy. +CraftBeerPI的用户友好性鼓舞我设置了另一个控制器来运行“发酵室”。就我来说,那是一个二手冰箱,我用了50美元加25美元的加热器设置在里边。CraftBeerPI很容易控制电器元件的冷热,你也能够设置多个温度阶段。举个例子,这个图表显示我最近做的IPA进程的发酵温度。发酵室发酵麦芽汁在67F的温度下需要4天,然后每到12小时上升一度直到温度到达72F。温度保持剩下两天是为了双乙酰生成。之后5天温度降到65F,这段时间是让啤酒变“干”,最后啤酒发酵温度直接降到38F。CraftBeerPI加入了每个阶段,让软件管理发酵更加容易。 ### [aedo-f5.png][15] ![SIPA fermentation profile](https://opensource.com/sites/default/files/aedo-f5.png "SIPA fermentation profile") -SIPA fermentation profile (photo by Christopher Aedo. [CC BY-SA 4.0)][9] +SIPA 发酵文档 (photo by Christopher Aedo. [CC BY-SA 4.0)][9] -I have also been experimenting with the [TILT hydrometer][42] to monitor the gravity of the fermenting beer via a Bluetooth-connected floating sensor. There are integration plans for this to get it working with CraftBeerPI, but for now it logs the gravity to a Google spreadsheet. Once this hydrometer can talk to the fermentation controller, setting automated fermentation profiles that take action directly based on the yeast activity would be easy—rather than banking on primary fermentation completing in four days, you can set the temperature ramp to kick off after the gravity is stable for 24 hours. +我也试验过用液体比重计来发对酵啤酒的重力进行监测,通过蓝牙连接的浮动传感器可以达到。有一个整合的计划能让CraftbeerPi很好工作,但是现在它记录这些重力数据到谷歌的电子表格里。一旦这个液体比重计能连接到发酵控制器,设置的自动发酵文档会基于酵母的活动性直接运行且更加容易,而不是在4天存贮的主要发酵完成,可以在重力24小时稳定在设定温度。 -As with any project like this, imaging and planning improvements and additional components is easy. Still, I'm happy with where things stand today. I've brewed a lot of beer with this setup and am hitting the expected mash efficiency every time, and the beer has been consistently tasty. My most important customer—me!—is pleased with what I've been putting on tap in my kitchen. + +像这样的一些项目,想象力和计划改进和额外的部件是很容易,不过,我很高兴今天经历过的事情。我用这种装置酿造了很多啤酒,每次都能达到预期的麦芽汁效率,而且啤酒一直都很美味。我最重要的消费者!-我,很高兴我可以随时饮用。 ### [aedo-f6.png][16] ![Homebrew on tap](https://opensource.com/sites/default/files/aedo-f6.png "Homebrew on tap") -Homebrew on tap (photo by Christopher Aedo. [CC BY-SA 4.0)][10] +随时饮用 (photo by Christopher Aedo. [CC BY-SA 4.0)][10] - _This article is based on Christopher's OpenWest talk, [Brewing Beer with Linux, Python and a RaspberryPi][18]. [OpenWest][19] will be held July 12-15, 2017 in Salt Lake City, Utah._ + 这篇文章基于克里斯托弗的开放的西部的谈话,用Linux,Python和树莓派酿制啤酒。 这次谈话将在2017年7月12-15日盐湖城举行。 -------------------------------------------------------------------------------- 作者简介: -Christopher Aedo - Christopher Aedo has been working with and contributing to open source software since his college days. Most recently he can be found leading an amazing team of upstream developers at IBM who are also developer advocates. When he’s not at work or speaking at a conference, he’s probably using a RaspberryPi to brew and ferment a tasty homebrew in Portland OR. +Christopher Aedo - Christopher Aedo 从他的学生时代就从事并且贡献于开源软件事业。最近他被发现是他在IBM领导一个逆流而上的开发者团队,同时他也是开发者拥护者。当他不再工作或者实在会议室演讲的时候,他可能在波特兰市俄勒冈州用树莓派酿制和发酵一杯美味的啤酒。 via: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi From a093b7363847738002fc2df4e56764d0375210cc Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 16:22:31 +0800 Subject: [PATCH 008/485] Rename Transleted20170703 Brewing beer with Linux python and raspberry pi.md to 20170703 Brewing beer with Linux python and raspberry pi.md --- ...> 20170703 Brewing beer with Linux python and raspberry pi.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{Transleted20170703 Brewing beer with Linux python and raspberry pi.md => 20170703 Brewing beer with Linux python and raspberry pi.md} (100%) diff --git a/translated/tech/Transleted20170703 Brewing beer with Linux python and raspberry pi.md b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md similarity index 100% rename from translated/tech/Transleted20170703 Brewing beer with Linux python and raspberry pi.md rename to translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md From 2cde5eeda1062b4de508210b3905e97dde98d8ce Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Oct 2017 17:40:16 +0800 Subject: [PATCH 009/485] =?UTF-8?q?=E8=A1=A5=E5=AE=8C=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @hwlife --- ...beer with Linux python and raspberry pi.md | 193 ------------------ 1 file changed, 193 deletions(-) delete mode 100644 sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md diff --git a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md deleted file mode 100644 index d9bd699d63..0000000000 --- a/sources/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ /dev/null @@ -1,193 +0,0 @@ -hwlife is translating -Brewing beer with Linux, Python, and Raspberry Pi -============================================================ - -### A handy how-to for building a homemade homebrew setup with Python and the Raspberry Pi. - - -![Brewing beer with Linux, Python, and Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/beer-drink-sample-sampler.png?itok=20jJLB8V "Brewing beer with Linux, Python, and Raspberry Pi") -Image by :  - -[Quinn Dombrowski][21]. Modified by Opensource.com. [CC BY-SA 4.0][22]. - -I started brewing my own beer more than 10 years ago. Like most homebrewers, I started in my kitchen making extract-based brews. This required the least equipment and still resulted in really tasty beer. Eventually I stepped up to all-grain brewing using a big cooler for my mash tun. For several years I was brewing 5 gallons at a time, but brewing 10 gallons takes the same amount of time and effort (and only requires slightly larger equipment), so a few years ago I stepped it up. After moving up to 10 gallons, I stumbled across [StrangeBrew Elsinore][23] and realized what I  _really_  needed to do was convert my whole system to be all-electric, and run it with a [Raspberry Pi][24]. - -There is a ton of great information available for building your own all-electric homebrew system, and most brewers start out at [TheElectricBrewery.com][25]. Just putting together the control panel can get pretty complicated, although the simplest approach is outlined well there. Of course you can also take [a less expensive approach][26] and still end up with the same result—a boil kettle and hot liquor tank powered by heating elements and managed by a PID controller. I think that's a little too boring though (and it also means you don't get neat graphs of your brew process). - -More on Raspberry Pi - -* [Our latest on Raspberry Pi][1] - -* [What is Raspberry Pi?][2] - -* [Getting started with Raspberry Pi][3] - -* [Send us your Raspberry Pi projects and tutorials][4] - -### Hardware supplies - -Before I talked myself out of the project, I decided to start buying parts. My basic design was a Hot Liquor Tank (HLT) and boil kettle with 5500w heating elements in them, plus a mash tun with a false bottom. I would use a pump to recirculate the mash through a 50' stainless coil in the HLT (a ["heat exchanger recirculating mash system", known as HERMS][27]). I would need a second pump to circulate the water in the HLT, and to help with transferring water to the mash tun. All of the electrical components would be controlled with a Raspberry Pi. - -Building my electric brew system and automating as much of it as possible meant I was going to need the following: - -* HLT with a 5500w electric heating element - -* HERMS coil (50' 1/2" stainless steel) in the HLT - -* boil kettle with a 5500w electric heating element - -* multiple solid-state relays to switch the heaters on and off - -* 2 high-temp food-grade pumps - -* relays for switching the pumps on and off - -* fittings and high-temp silicon tubing - -* stainless ball valves - -* 1-wire temperature probes - -* lots of wire - -* electrical box to hold everything - -### [aedo-f1.png][11] - -![Brew system](https://opensource.com/sites/default/files/aedo-f1.png "Brew system") - -Brew system (photo by Christopher Aedo. [CC BY-SA 4.0)][5] - -The details of building out the electrical side of the system are really well covered by [The Electric Brewery][28], so I won't repeat their detailed information. You can read through and follow their suggestions while planning to replace the PID controllers with a Raspberry Pi. - -One important thing to note is the solid-state relay (SSR) signal voltage. Many tutorials suggest using SSRs that need a 12-volt signal to close the circuit. The Raspberry Pi GPIO pins will only output 3v, however. Be sure to purchase relays that will trigger on 3 volts. - -### [aedo-f2.png][12] - -![Inkbird SSR](https://opensource.com/sites/default/files/aedo-f2.png "Inkbird SSR") - -Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6] - -To run your brew system, your Pi must do two key things: sense temperature from a few different places, and turn relays on and off to control the heating elements. The Raspberry Pi easily is able to handle these tasks. - -There are a few different ways to connect temp sensors to a Pi, but I've found the most convenient approach is to use the [1-Wire bus][29]. This allows for multiple sensors to share the same wire (actually three wires), which makes it a convenient way to instrument multiple components in your brew system. If you look for waterproof DS18B20 temperature sensors online, you'll find lots of options available. I used [Hilitchi DS18B20 Waterproof Temperature Sensors][30] for my project. - -To control the heating elements, the Raspberry Pi includes several General Purpose IO (GPIO) pins that are software addressable. This allows you to send 3.3v to a relay by simply putting a **1** or a **0** in a file. The  _Raspberry Pi—Driving a Relay using GPIO_  tutorial was the most helpful for me when I was first learning how all this worked. The GPIO controls multiple solid-state relays, turning on and off the heating elements as directed by the brewing software. - -I first started working on the box to hold all the components. Because this would all be on a rolling cart, I wanted it to be relatively portable rather than permanently mounted. If I had a spot (for example, inside a garage, utility room, or basement), I would have used a larger electrical box mounted on the wall. Instead I found a decent-size [waterproof project box][31] that I expected I could shoehorn everything into. In the end, it turned out to be a little bit of a tight fit, but it worked out. In the bottom left corner is the Pi with a breakout board for connecting the GPIO to the 1-Wire temperature probes and the [solid state relays][32]. - -To keep the 240v SSRs cool, I cut holes in the case and stacked [copper shims][33] with CPU cooling grease between them and heat sinks mounted on the outside of the box. It worked out well and there haven't been any cooling issues inside the box. On the cover I put two switches for 120v outlets, plus two 240v LEDs to show which heating element was energized. I used dryer plugs and outlets for all connections so disconnecting a kettle from everything is easy. Everything worked right on the first try, too. (Sketching a wiring diagram first definitely pays off.) - -The pictures are from the "proof-of-concept" version—the final production system should have two more SSRs so that both legs of the 240v circuit would be switched. The other thing I would like to switch via software is the pumps. Right now they're controlled via physical switches on the front of the box, but they could easily be controlled with relays. - -### [aedo-f3.png][13] - -![Control box](https://opensource.com/sites/default/files/aedo-f3.png "Control box") - -Control box (photo by Christopher Aedo. [CC BY-SA 4.0)][7] - -The only other thing I needed that was a little tricky to find was a compression fitting for the temperature probes. The probes were mounted in T fittings before the valve on the lowest bulkhead in both the HLT and the mash tun. As long as the liquid is flowing past the temp sensor, it's going to be accurate. I thought about adding a thermowell into the kettles as well, but realized that's not going to be useful for me based on my brewing process. Anyway, I purchased [1/4" compression fittings][34] and they worked out perfectly. - -### Software - -Once the hardware was sorted out, I had time to play with the software. I ran the latest [Raspbian distribution][35] on the Pi; nothing special was required on the operating-system side. - -I started with [Strangebrew Elsinore][36] brewing software, which I had discovered when a friend asked whether I had heard of [Hosehead][37], a Raspberry Pi-based brewing controller. I thought Hosehead looked great, but rather than buying a brewing controller, I wanted the challenge of building my own. - -Setting up Strangebrew Elsinore was straightforward—the [documentation][38] was thorough and I did not encounter any problems. Even though Strangebrew Elsinore was working fine, Java seemed to be taxing my first-generation Pi sometimes, and it crashed on me more than once. I also was sad to see development stall and there did not seem to be a big community of additional contributors (although there were—and still are—plenty of people using it). - -### CraftBeerPi - -Then I stumbled across [CraftBeerPI][39], which is written in Python and supported by a development community of active contributors. The original author (and current maintainer) Manuel Fritsch is great about handling contributions and giving feedback on issues that folks open. Cloning [the repo][40] and getting started only took me a few minutes. The README also has a good example of connecting DS1820 temp sensors, along with notes on interfacing hardware to a Pi or a [C.H.I.P. computer][41]. - -On startup, CraftBeerPi walks users through a configuration process that discovers the temperature probes available and lets you specify which GPIO pins are managing which pieces of equipment. - -### [aedo-f4.png][14] - -![CraftBeerPi](https://opensource.com/sites/default/files/images/life/aedo-f4.png "CraftBeerPi") - -CraftBeerPi (photo by Christopher Aedo. [CC BY-SA 4.0)][8] - -Running a brew with this system is easy. I can count on it holding temperatures reliably, and I can input steps for a multi-temp step mash. Using CraftBeerPi has made my brew days a little bit boring, but I'm happy to trade off the "excitement" of traditional manually managed propane burners for the efficiency and consistency of this system. - -CraftBeerPI's user-friendliness inspired me to set up another controller to run a "fermentation chamber." In my case, that was a second-hand refrigerator I found for US$ 50 plus a $25 heater) on the inside. CraftBeerPI easily can control the cooling and heating elements, and you can set up multiple temperature steps. For instance, this graph shows the fermentation temperatures for a session IPA I made recently. The fermentation chamber held the fermenting wort at 67F for four days, then ramped up one degree every 12 hours until it was at 72F. That temp was held for a two-day diacetyl rest. After that it was set to drop down to 65F for five days, during which time I "dry hopped" the beer. Finally, the beer was cold-crashed down to 38F. CraftBeerPI made adding each step and letting the software manage the fermentation easy. - -### [aedo-f5.png][15] - -![SIPA fermentation profile](https://opensource.com/sites/default/files/aedo-f5.png "SIPA fermentation profile") - -SIPA fermentation profile (photo by Christopher Aedo. [CC BY-SA 4.0)][9] - -I have also been experimenting with the [TILT hydrometer][42] to monitor the gravity of the fermenting beer via a Bluetooth-connected floating sensor. There are integration plans for this to get it working with CraftBeerPI, but for now it logs the gravity to a Google spreadsheet. Once this hydrometer can talk to the fermentation controller, setting automated fermentation profiles that take action directly based on the yeast activity would be easy—rather than banking on primary fermentation completing in four days, you can set the temperature ramp to kick off after the gravity is stable for 24 hours. - -As with any project like this, imaging and planning improvements and additional components is easy. Still, I'm happy with where things stand today. I've brewed a lot of beer with this setup and am hitting the expected mash efficiency every time, and the beer has been consistently tasty. My most important customer—me!—is pleased with what I've been putting on tap in my kitchen. - -### [aedo-f6.png][16] - -![Homebrew on tap](https://opensource.com/sites/default/files/aedo-f6.png "Homebrew on tap") - -Homebrew on tap (photo by Christopher Aedo. [CC BY-SA 4.0)][10] - - _This article is based on Christopher's OpenWest talk, [Brewing Beer with Linux, Python and a RaspberryPi][18]. [OpenWest][19] will be held July 12-15, 2017 in Salt Lake City, Utah._ - --------------------------------------------------------------------------------- - -作者简介: - -Christopher Aedo - Christopher Aedo has been working with and contributing to open source software since his college days. Most recently he can be found leading an amazing team of upstream developers at IBM who are also developer advocates. When he’s not at work or speaking at a conference, he’s probably using a RaspberryPi to brew and ferment a tasty homebrew in Portland OR. - - -via: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi - -作者:[ Christopher Aedo][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/docaedo -[1]:https://opensource.com/tags/raspberry-pi?src=raspberry_pi_resource_menu1 -[2]:https://opensource.com/resources/what-raspberry-pi?src=raspberry_pi_resource_menu2 -[3]:https://opensource.com/article/16/12/getting-started-raspberry-pi?src=raspberry_pi_resource_menu3 -[4]:https://opensource.com/article/17/2/raspberry-pi-submit-your-article?src=raspberry_pi_resource_menu4 -[5]:https://creativecommons.org/licenses/by-sa/4.0/ -[6]:https://creativecommons.org/licenses/by-sa/4.0/ -[7]:https://creativecommons.org/licenses/by-sa/4.0/ -[8]:https://creativecommons.org/licenses/by-sa/4.0/ -[9]:https://creativecommons.org/licenses/by-sa/4.0/ -[10]:https://creativecommons.org/licenses/by-sa/4.0/ -[11]:https://opensource.com/file/358661 -[12]:https://opensource.com/file/358666 -[13]:https://opensource.com/file/358676 -[14]:https://opensource.com/file/359061 -[15]:https://opensource.com/file/358681 -[16]:https://opensource.com/file/359071 -[17]:https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi?rate=fbKzT1V9gqGsmNCTuQIashC1xaHT5P_2LUaeTn6Kz1Y -[18]:https://www.openwest.org/custom/description.php?id=139 -[19]:https://www.openwest.org/ -[20]:https://opensource.com/user/145976/feed -[21]:https://www.flickr.com/photos/quinndombrowski/ -[22]:https://creativecommons.org/licenses/by-sa/4.0/ -[23]:https://github.com/DougEdey/SB_Elsinore_Server -[24]:https://opensource.com/tags/raspberry-pi -[25]:http://www.theelectricbrewery.com/ -[26]:http://www.instructables.com/id/Electric-Brewery-Control-Panel-on-the-Cheap/ -[27]:https://byo.com/hops/item/1325-rims-and-herms-brewing-advanced-homebrewing -[28]:http://theelectricbrewery.com/ -[29]:https://en.wikipedia.org/wiki/1-Wire -[30]:https://smile.amazon.com/gp/product/B018KFX5X0/ -[31]:http://amzn.to/2hupFCr -[32]:http://amzn.to/2hL8JDS -[33]:http://amzn.to/2i4DYwy -[34]:https://www.brewershardware.com/CF1412.html -[35]:https://www.raspberrypi.org/downloads/raspbian/ -[36]:https://github.com/DougEdey/SB_Elsinore_Server -[37]:https://brewtronix.com/ -[38]:http://dougedey.github.io/SB_Elsinore_Server/ -[39]:http://www.craftbeerpi.com/ -[40]:https://github.com/manuel83/craftbeerpi -[41]:https://www.nextthing.co/pages/chip -[42]:https://tilthydrometer.com/ -[43]:https://opensource.com/users/docaedo -[44]:https://opensource.com/users/docaedo -[45]:https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi#comments From a2dc84c2a0a4825e2c8eb70e484b72044693af96 Mon Sep 17 00:00:00 2001 From: hwlife <30950568+hwlife@users.noreply.github.com> Date: Sun, 8 Oct 2017 19:15:40 +0800 Subject: [PATCH 010/485] Update 20170908 Betting on the Web.md --- sources/tech/20170908 Betting on the Web.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20170908 Betting on the Web.md b/sources/tech/20170908 Betting on the Web.md index 84d70e164f..5a5746e681 100644 --- a/sources/tech/20170908 Betting on the Web.md +++ b/sources/tech/20170908 Betting on the Web.md @@ -1,3 +1,4 @@ +translate by hwlife [Betting on the Web][27] ============================================================ From 097d87744330c68f9b6e5abadd7006eb1c07d9b9 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Oct 2017 21:28:57 +0800 Subject: [PATCH 011/485] PRF:20170703 Brewing beer with Linux python and raspberry pi.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @hwlife 语言能力不错,也对所翻译领域比较熟悉。不过后半部分有点疲倦了。此外, 要注意保留文章中的 markdown 标记(尤其是链接)。 --- ...beer with Linux python and raspberry pi.md | 129 ++++++------------ 1 file changed, 45 insertions(+), 84 deletions(-) diff --git a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md index 29a9613204..08a7a1cd55 100644 --- a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md +++ b/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md @@ -1,152 +1,112 @@ -用Linux,Python和树莓派酿制啤酒 +用 Linux、Python 和树莓派酿制啤酒 ============================================================ -### 怎样在家用python和树莓派搭建一个家用便携的自制酿啤酒装置 - +> 怎样在家用 Python 和树莓派搭建一个家用便携的自制酿啤酒装置 -![Brewing beer with Linux, Python, and Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/beer-drink-sample-sampler.png?itok=20jJLB8V "Brewing beer with Linux, Python, and Raspberry Pi") -Image by :  +![Brewing beer with Linux, Python, and Raspberry Pi](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/beer-drink-sample-sampler.png?itok=JV4E4iVY "Brewing beer with Linux, Python, and Raspberry Pi") -[Quinn Dombrowski][21]. Modified by Opensource.com. [CC BY-SA 4.0][22]. +大约十年前我开始酿制自制啤酒,和许多自己酿酒的人一样,我开始在厨房制造提纯啤酒。这需要一些设备并且做出来后确实是好的啤酒,最终,我用一个放入了所有大麦的大贮藏罐作为我的麦芽浆桶。几年之后我一次酿制过 5 加仑啤酒,但是酿制 10 加仑时也会花费同样的时间和效用(只是容器比之前大些),之前我就是这么做的。容量提升到 10 加仑之后,我偶然看到了 [StrangeBrew Elsinore][38] ,我意识到我真正需要的是将整个酿酒过程转换成全电子化的,用树莓派来运行它。 -大约十年前我开始酿制自制啤酒,和许多自己酿酒的人一样,我开始在厨房制造提纯啤酒。这需要一些设备并且做出来后确实是好的啤酒,最终,我用一个大的贮藏罐放入了所有大麦作为我的麦芽浆桶。几年之后我曾酿制了5加仑啤酒,但是酿制10加仑时会花费同样的时间和效用(只是容器比之前大些),之前我是这么做的。容量提升到10加仑之后,我偶然发现并意识到我真正需要的是将整个酿酒过程转换成全电子化的,用树莓派来运行它。 - -建造自己的家用电动化酿酒系统需要大量这方面的技术信息,许多学习酿酒的是在TheElectricBrewery.com这个网站起步的,只不过将那些控制版搭建在一起是十分复杂的,尽管最简单的办法在这个网站上总结的很好。当然你也能用一个小成本的方法并且依旧可以用相同的结果得到-用一个热水壶和热酒容器通过一个PID控制器来加热你的酿酒原料。但是我认为这有点太无聊(这也意味着你不能get到完成酿酒过程) - -关于树莓派更多信息 - -* [关于树莓派最新消息[1] - -* [树莓派是什么?][2] - -* [树莓派如何开始使用][3] - -* [发送给我们你的树莓派项目和教程][4] +建造自己的家用电动化酿酒系统需要大量这方面的技术信息,许多学习酿酒的人是在 [TheElectricBrewery.com][28] 这个网站起步的,只不过将那些控制版搭建在一起是十分复杂的,尽管最简单的办法在这个网站上总结的很好。当然你也能用[一个小成本的方法][26]并且依旧可以得到相同的结果 —— 用一个热水壶和热酒容器通过一个 PID 控制器来加热你的酿酒原料。但是我认为这有点太无聊(这也意味着你不能体验到完整的酿酒过程)。 ### 需要用到的硬件 -在我开始我得这个项目之前, 我决定开始买零件,我最基础的设计是一个可以将液体加热到5500w的热酒容器和开水壶,加一个活底的麦芽浆桶,我通过一个50的不锈钢线圈在热酒容器里让泵来再循环麦芽浆(a ["热量交换再循环麦芽浆系统, 也叫 HERMS][27]).同时我需要另一个泵来在热酒容器里循环水,并且把水传输到麦芽浆桶里,整个电子部件全部是用树莓派来控制的。 +在我开始我的这个项目之前, 我决定开始买零件,我最基础的设计是一个可以将液体加热到 5500 瓦的热酒容器(HLT)和开水壶,加一个活底的麦芽浆桶,我通过一个 50 英尺的不锈钢线圈在热酒容器里让泵来再循环麦芽浆(["热量交换再循环麦芽浆系统, 也叫 HERMS][27])。同时我需要另一个泵来在热酒容器里循环水,并且把水传输到麦芽浆桶里,整个电子部件全部是用树莓派来控制的。 +建立我的电子酿酒系统并且尽可能的自动化意味着我需要以下的组件: -建立我得电子酿酒系统并且尽可能的自动化意味着我需要以下的东东: - - -* 一个5500瓦的电子加热酒精容器 - -* 能够放入加热酒精容器里的一英尺(0.5英寸)长的不锈钢线圈(热量交换再循环麦芽浆系统) - -* 一个5500瓦的电子加热水壶 - +* 一个 5500 瓦的电子加热酒精容器(HLT) +* 能够放入加热酒精容器里的 50 英尺(0.5 英寸)的不锈钢线圈(热量交换再循环麦芽浆系统) +* 一个 5500 瓦的电子加热水壶 * 多个固态继电器加热开关 - -* 2个高温食品级泵 - +* 2 个高温食品级泵 * 泵的开关用继电器 - * 可拆除装置和一个硅管 - * 不锈钢球阀 - * 一个测量温度的探针 - * 很多线 - * 一个来容纳这些配件的电路盒子 -### [aedo-f1.png][11] - ![Brew system](https://opensource.com/sites/default/files/aedo-f1.png "Brew system") -酿酒系统 (photo by Christopher Aedo. [CC BY-SA 4.0)][5] +*酿酒系统 (photo by Christopher Aedo. [CC BY-SA 4.0)][5]* -建立酿酒系统的电气化方面的细节The Electric Brewery这个网站概括的很好,这里我不再重复,当你计划用树莓派代替这个PID控制器的话,你可以读以下的建议。 +建立酿酒系统的电气化方面的细节 [The Electric Brewery][28] 这个网站概括的很好,这里我不再重复,当你计划用树莓派代替这个 PID 控制器的话,你可以读以下的建议。 -一个重要的事情需要注意,固态继电器信号电压,许多教程建议使用一个12伏的固态继电器来关闭电路,树莓派的GPIO针插口只支持输出电压3伏,然而,必须购买继电器将电压变为3伏。 - -### [aedo-f2.png][12] +一个重要的事情需要注意,固态继电器(SSR)信号电压,许多教程建议使用一个 12 伏的固态继电器来关闭电路,树莓派的 GPIO 针插口只支持 3 伏输出电压,然而,必须购买继电器将电压变为 3 伏。 ![Inkbird SSR](https://opensource.com/sites/default/files/aedo-f2.png "Inkbird SSR") -Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6] +*Inkbird SSR (photo by Christopher Aedo. [CC BY-SA 4.0)][6]* -要运行酿酒系统,你的树莓派必须做两个关键事情:来自不同位置的敏感温度,用继电器开关来控制加热元件,树莓派很容易来处理这些任务。 +要运行酿酒系统,你的树莓派必须做两个关键事情:测量来自几个不同位置的温度,用继电器开关来控制加热元件,树莓派很容易来处理这些任务。 -这里有一些不同的方法来将温度传感器连到树莓派上,但是我找到了最方便的方法用单总线。这就可以让多个传感器分享相同的线路(实际上三根线),这三根线可以使酿酒系统的多个设备更方便的工作,如果你要从网上找一个DS18B20 防水的温度传感器,你将会找到更多的选择。我用的是日立DS18B20防水温度传感器。 +这里有一些不同的方法来将温度传感器连到树莓派上,但是我找到了最方便的方法用[单总线][29]。这就可以让多个传感器分享相同的线路(实际上是三根线),这三根线可以使酿酒系统的多个设备更方便的工作,如果你要从网上找一个防水的 DS18B20 温度传感器,你可以会找到很多选择。我用的是[日立 DS18B20 防水温度传感器][30]。 -要控制加热元件,树莓派包括几个用来软件寻址的总线扩展器(GPIO),它会通过在某个文件写入0或者1让你发送3.3v的电压到一个继电器,在我第一次了解树莓派是怎样工作的时候,这个用GPIO驱动继电器的树莓派教程对我来说是最有帮助的,总线控制器控制多个固态继电器,通过酿酒软件来直接控制加热元件的开关。 +要控制加热元件,树莓派包括了几个用来软件寻址的总线扩展器(GPIO),它会通过在某个文件写入 0 或者 1 让你发送3.3v 的电压到一个继电器,在我第一次了解树莓派是怎样工作的时候,这个[用 GPIO 驱动继电器的树莓派教程][46]对我来说是最有帮助的,总线扩展器控制着多个固态继电器,通过酿酒软件来直接控制加热元件的开关。 -我第一次将所有部件放到这个电路盒子,因为这将成为一个滚动的小车,我要让他方便移动,而不是固定不动的,如果我有一个店(比如说在车库,工具房,或者地下室),我需要要用一个更大的电路盒挂到墙上,而现在我找到一个大小正好的防水工程盒子,能放进每件东西,最后它成为紧密的结合工具盒,并且能够工作。在左下角是和树莓派连接的为总线控制器到单总线温度探针和固态继电器的扩展板。 +我首先将所有部件放到这个电路盒子,因为这将成为一个滚动的小车,我要让它便于移动,而不是固定不动的,如果我有一个店(比如说在车库、工具房、或者地下室),我需要要用一个装在墙上的更大的电路盒,而现在我找到一个大小正好的[防水工程盒子][31],能放进每件东西,最后它成为小巧紧凑工具盒,并且能够工作。在左下角是和树莓派连接的为总线扩展器到单总线温度探针和[固态继电器][32]的扩展板。 -要保持240v的固态继电器温度不高,我在盒子上切了个洞,在盒子的外面用降温凝胶安装铜片散热片冷却cpu的温度。它工作的很好,盒子里没有温度上的问题了,在盒子盖上我放了两个开关为120v的插座,加两个240v的led来显示加热元件是否通电。我用干燥器的插座和插头很容易的开关电热水壶的连接。第一次尝试每件事情都弄好了。(决定第一次手画电路图.) +要保持 240v 的固态继电器温度不高,我在盒子上切了个洞,在盒子的外面用 CPU 降温凝胶把[铜片散热片][33]安装到盒子外面的热槽之间。它工作的很好,盒子里没有温度上的问题了,在盒子盖上我放了两个开关为 120v 的插座,加两个240v 的 led 来显示加热元件是否通电。我用干燥器的插座和插头,所以可以很容易的断开电热水壶的连接。首次尝试每件事情都工作正常。(第一次绘制电路图必有回报) - -照片是从“概念”版的最终生产系统应该有两个固态继电器,以至于240v的电路两个针脚能够切换,另外我将通过软件来切换泵的开关,。现在他们通过盒子前面的物理开关控制,但是他们很容易用继电器控制。 - - -### [aedo-f3.png][13] +这个照片来自“概念”版,最终生产系统应该有两个以上的固态继电器,以便 240v 的电路两个针脚能够切换,另外我将通过软件来切换泵的开关。现在通过盒子前面的物理开关控制它们,但是也很容易用继电器控制它们。 ![Control box](https://opensource.com/sites/default/files/aedo-f3.png "Control box") -控制盒子 (photo by Christopher Aedo. [CC BY-SA 4.0)][7] +*控制盒子 (photo by Christopher Aedo. [CC BY-SA 4.0)][7]* -另一个事情是我要为温度探针找一个微型压缩装置,这个探针以T字型装置在加热酒精容器和麦芽浆桶球形阀门的最底部,只要是液体流过温度传感器,温度是准确显示的。我考虑加一个套管到热水壶里,但是基于我的酿造工艺没有什么用。无论如何,我买四分之一英寸的压缩配件,他们是完美的。 +唯一剩下有点棘手的事情是温度探针的压合接头,这个探针安装在加热酒精容器和麦芽浆桶球形的最底部阀门前的 T 字型接头上。当液体流过温度传感器,温度可以准确显示。我考虑加一个套管到热水壶里,但是对于我的酿造工艺没有什么用。最后,我买到了[四分之一英寸的压合接头][34],它们工作完美。 ### 软件 -一旦硬件整理好,我有时间来处理软件,我在树莓派上跑了最新的发行版,操作系统方面没有什么特别的。 +一旦硬件整理好,我就有时间来处理软件了,我在树莓派上跑了最新的 [Raspbian 发行版][35],操作系统方面没有什么特别的。 -我开始使用Strangebrew Elsinore酿酒软件,当我的朋友问我是否我听说过[Hosehead],一个基于树莓派的酿酒控制器,那时我已经听说过这个软件了。我认为[Hosehead]很棒,但并不是要买一个酿酒控制器,贰拾我要挑战自己搭建我自己的一个。 +我开始使用 [Strangebrew Elsinore][36] 酿酒软件,当我的朋友问我是否我听说过 [Hosehead][37](一个基于树莓派的酿酒控制器),我找到了 [Strangebrew Elsinore][36] 。我认为 [Hosehead][37] 很棒,但我并不是要买一个酿酒控制器,而是要挑战自己,搭建一个自己的。 -设置Strangebrew Elsinore 这个软件是按照说明文档操作,没有遇到任何的问题。尽管Strangebrew Elsinore工作的很好,在一代树莓派上运行java有时是费力的,不止崩溃一次。我看到这个软件开发停顿也很伤心,因为他们没有几个看起来很大的贡献者的社区(尽管有很多人还在用它) +设置 [Strangebrew Elsinore][36] 很简单,其[文档][38]直白,没有遇到任何的问题。尽管 Strangebrew Elsinore 工作的很好,但在我的一代树莓派上运行 java 有时是费力的,不止崩溃一次。我看到这个软件开发停顿也很伤心,似乎他们也没有更多贡献者的大型社区(尽管有很多人还在用它)。 +#### CraftBeerPi -### CraftBeerPi +之后我偶然遇到了一个用 Python 写的 [CraftbeerPI][39],它有活跃的贡献者支持的开发社区。原作者(也是当前维护者) Manuel Fritsch 在贡献和反馈问题处理方面做的很好。克隆[这个仓库][40]然后开始只用了我一点时间。其 README 文档也是一个连接 DS1820 温度传感器的好例子,同时也有关于硬件接口到树莓派或者[芯片电脑][41] 的注意事项。 -之后我偶然遇到了一个用Python写的支持活跃的贡献者的开发社区的CraftbeerPI,应该叫手工啤酒派吧。原作者和当前维护者Manuel Fritsch在做贡献和反馈问题是友好的。克隆这个仓库然后开始花了我一些时间。README文档也是一个连接DS1820温度传感器的好例子,同时注意关于硬件接口到树莓派或者芯片电脑。 - -在启动的时候,CraftbeerPI引导用户通过一个设置过程来发现温度探针是否可用,并且让你用GPIO总线控制器来管理树莓派上的特定设备部件 - -### [aedo-f4.png][14] +在启动的时候,CraftbeerPI 引导用户通过一个设置过程来发现温度探针是否可用,并且让你指定哪个 GPIO 总线扩展器指针来管理树莓派上哪个配件。 ![CraftBeerPi](https://opensource.com/sites/default/files/images/life/aedo-f4.png "CraftBeerPi") -CraftBeerPi (photo by Christopher Aedo. [CC BY-SA 4.0)][8] +*CraftBeerPi (photo by Christopher Aedo. [CC BY-SA 4.0)][8]* -运行自制酿酒系统是容易的,我能够依靠它掌握可靠的温度,我能输入多个温度段来控制麦芽浆温度,用CraftbeerPi酿酒的日子有一点点累,但是传统手工管理丙烷燃烧器为系统的有效性和持续性我还是很高兴的。 +用这个系统进行自制酿酒是容易的,我能够依靠它掌握可靠的温度,我能输入多个温度段来控制麦芽浆温度,用CraftbeerPi 酿酒的日子有一点点累,但是我很高兴用传统的手工管理丙烷燃烧器的“兴奋”来换取这个系统的有效性和持续性。 -CraftBeerPI的用户友好性鼓舞我设置了另一个控制器来运行“发酵室”。就我来说,那是一个二手冰箱,我用了50美元加25美元的加热器设置在里边。CraftBeerPI很容易控制电器元件的冷热,你也能够设置多个温度阶段。举个例子,这个图表显示我最近做的IPA进程的发酵温度。发酵室发酵麦芽汁在67F的温度下需要4天,然后每到12小时上升一度直到温度到达72F。温度保持剩下两天是为了双乙酰生成。之后5天温度降到65F,这段时间是让啤酒变“干”,最后啤酒发酵温度直接降到38F。CraftBeerPI加入了每个阶段,让软件管理发酵更加容易。 - -### [aedo-f5.png][15] +CraftBeerPI 的用户友好性鼓舞我设置了另一个控制器来运行“发酵室”。就我来说,那是一个二手冰箱,我用了 50 美元加上放在里面的 25 美元的加热器。CraftBeerPI 很容易控制电器元件的冷热,你也能够设置多个温度阶段。举个例子,这个图表显示我最近做的 IPA 进程的发酵温度。发酵室发酵麦芽汁在 67F° 的温度下需要 4 天,然后每 12 小时上升一度直到温度到达 72F°。剩下两天温度保持不变是为了双乙酰生成。之后 5 天温度降到 65F°,这段时间是让啤酒变“干”,最后啤酒发酵温度直接降到 38F°。CraftBeerPI 可以加入各个阶段,让软件管理发酵更加容易。 ![SIPA fermentation profile](https://opensource.com/sites/default/files/aedo-f5.png "SIPA fermentation profile") -SIPA 发酵文档 (photo by Christopher Aedo. [CC BY-SA 4.0)][9] +*SIPA 发酵设置 (photo by Christopher Aedo. [CC BY-SA 4.0)][9]* -我也试验过用液体比重计来发对酵啤酒的重力进行监测,通过蓝牙连接的浮动传感器可以达到。有一个整合的计划能让CraftbeerPi很好工作,但是现在它记录这些重力数据到谷歌的电子表格里。一旦这个液体比重计能连接到发酵控制器,设置的自动发酵文档会基于酵母的活动性直接运行且更加容易,而不是在4天存贮的主要发酵完成,可以在重力24小时稳定在设定温度。 +我也试验过用[液体比重计][42]来对酵啤酒的比重进行监测,通过蓝牙连接的浮动传感器可以达到。有一个整合的计划能让 CraftbeerPi 很好工作,现在它记录这些比重数据到谷歌的电子表格里。一旦这个液体比重计能连接到发酵控制器,设置的自动发酵设置会基于酵母的活动性直接运行且更加容易,而不是在 4 天内完成主要发酵,可以在比重稳定 24 小时后设定温度。 - -像这样的一些项目,想象力和计划改进和额外的部件是很容易,不过,我很高兴今天经历过的事情。我用这种装置酿造了很多啤酒,每次都能达到预期的麦芽汁效率,而且啤酒一直都很美味。我最重要的消费者!-我,很高兴我可以随时饮用。 - -### [aedo-f6.png][16] +像这样的一些项目,构想并计划改进和增加组件是很容易,不过,我很高兴今天经历过的事情。我用这种装置酿造了很多啤酒,每次都能达到预期的麦芽汁比率,而且啤酒一直都很美味。我的最重要的消费者 —— 就是我!很高兴我可以随时饮用。 ![Homebrew on tap](https://opensource.com/sites/default/files/aedo-f6.png "Homebrew on tap") -随时饮用 (photo by Christopher Aedo. [CC BY-SA 4.0)][10] +*随时饮用 (photo by Christopher Aedo. [CC BY-SA 4.0)][10]* - 这篇文章基于克里斯托弗的开放的西部的谈话,用Linux,Python和树莓派酿制啤酒。 这次谈话将在2017年7月12-15日盐湖城举行。 +这篇文章基于 Christopher 的开放的西部的讲话《用Linux、Python 和树莓派酿制啤酒》。 + +(题图:[Quinn Dombrowski][21]. Modified by Opensource.com. [CC BY-SA 4.0][22]) -------------------------------------------------------------------------------- 作者简介: -Christopher Aedo - Christopher Aedo 从他的学生时代就从事并且贡献于开源软件事业。最近他被发现是他在IBM领导一个逆流而上的开发者团队,同时他也是开发者拥护者。当他不再工作或者实在会议室演讲的时候,他可能在波特兰市俄勒冈州用树莓派酿制和发酵一杯美味的啤酒。 - +Christopher Aedo 从他的学生时代就从事并且贡献于开源软件事业。最近他在 IBM 领导一个极棒的上游开发者团队,同时他也是开发者拥护者。当他不再工作或者实在会议室演讲的时候,他可能在波特兰市俄勒冈州用树莓派酿制和发酵一杯美味的啤酒。 +---- via: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi -作者:[ Christopher Aedo][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +作者:[Christopher Aedo][a] +译者:[hwlife](https://github.com/hwlife) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -196,3 +156,4 @@ via: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi [43]:https://opensource.com/users/docaedo [44]:https://opensource.com/users/docaedo [45]:https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi#comments +[46]:http://www.susa.net/wordpress/2012/06/raspberry-pi-relay-using-gpio/ \ No newline at end of file From 011215e2b4a655c36dafe8df1d519ceefe928fc5 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Oct 2017 21:32:53 +0800 Subject: [PATCH 012/485] PUB:20170703 Brewing beer with Linux python and raspberry pi.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @hwlife 本文发表地址: https://linux.cn/article-8942-1.html --- .../20170703 Brewing beer with Linux python and raspberry pi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170703 Brewing beer with Linux python and raspberry pi.md (100%) diff --git a/translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md b/published/20170703 Brewing beer with Linux python and raspberry pi.md similarity index 100% rename from translated/tech/20170703 Brewing beer with Linux python and raspberry pi.md rename to published/20170703 Brewing beer with Linux python and raspberry pi.md From cda4543a9871375acfeac8d655b0f0365193a2a6 Mon Sep 17 00:00:00 2001 From: wxy Date: Sun, 8 Oct 2017 22:41:06 +0800 Subject: [PATCH 013/485] PRF&PUB:20170801 Writing a Linux Debugger Part 10 Advanced topics.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @geekpi 终于又搞完一个系列。 --- ... Linux Debugger Part 10 Advanced topics.md | 79 ++++++------------- 1 file changed, 25 insertions(+), 54 deletions(-) rename {translated/tech => published}/20170801 Writing a Linux Debugger Part 10 Advanced topics.md (53%) diff --git a/translated/tech/20170801 Writing a Linux Debugger Part 10 Advanced topics.md b/published/20170801 Writing a Linux Debugger Part 10 Advanced topics.md similarity index 53% rename from translated/tech/20170801 Writing a Linux Debugger Part 10 Advanced topics.md rename to published/20170801 Writing a Linux Debugger Part 10 Advanced topics.md index 7e0d882082..61a02eb69d 100644 --- a/translated/tech/20170801 Writing a Linux Debugger Part 10 Advanced topics.md +++ b/published/20170801 Writing a Linux Debugger Part 10 Advanced topics.md @@ -1,95 +1,68 @@ 开发一个 Linux 调试器(十):高级主题 ============================================================ -我们终于来到这个系列的最后一篇文章!这一次,我将对调试中的一些更高级的概念进行高层的概述:远程调试、共享库支持、表达式计算和多线程支持。这些想法实现起来比较复杂,所以我不会详细说明如何做,但是如果有的话,我很乐意回答有关这些概念的问题。 - -* * * +我们终于来到这个系列的最后一篇文章!这一次,我将对调试中的一些更高级的概念进行高层的概述:远程调试、共享库支持、表达式计算和多线程支持。这些想法实现起来比较复杂,所以我不会详细说明如何做,但是如果你有问题的话,我很乐意回答有关这些概念的问题。 ### 系列索引 1. [准备环境][1] - 2. [断点][2] - 3. [寄存器和内存][3] - 4. [Elves 和 dwarves][4] - 5. [源码和信号][5] - 6. [源码层逐步执行][6] - 7. [源码层断点][7] - 8. [调用栈][8] - 9. [处理变量][9] - 10. [高级主题][10] -* * * - ### 远程调试 -远程调试对于嵌入式系统或不同环境的调试非常有用。它还在高级调试器操作和与操作系统和硬件的交互之间设置了一个很好的分界线。事实上,像 GDB 和 LLDB 这样的调试器即使在调试本地程序时也可以作为远程调试器运行。一般架构是这样的: +远程调试对于嵌入式系统或对不同环境进行调试非常有用。它还在高级调试器操作和与操作系统和硬件的交互之间设置了一个很好的分界线。事实上,像 GDB 和 LLDB 这样的调试器即使在调试本地程序时也可以作为远程调试器运行。一般架构是这样的: ![debugarch](https://blog.tartanllama.xyz/assets/debugarch.png) -调试器是我们通过命令行交互的组件。也许如果你使用的是 IDE,那么顶层中另一个层可以通过_机器接口_与调试器进行通信。在目标机器上(可能与本机一样)有一个 _debug stub_ ,它理论上是一个非常小的操作系统调试库的包装程序,它执行所有的低级调试任务,如在地址上设置断点。我说“在理论上”,因为如今 stub 变得越来越大。例如,我机器上的 LLDB debug stub 大小是 7.6MB。debug stub 通过一些使用特定于操作系统的功能(在我们的例子中是 “ptrace”)和被调试进程以及通过远程协议的调试器通信。 +调试器是我们通过命令行交互的组件。也许如果你使用的是 IDE,那么在其上有另一个层可以通过_机器接口_与调试器进行通信。在目标机器上(可能与本机一样)有一个调试存根debug stub ,理论上它是一个非常小的操作系统调试库的包装程序,它执行所有的低级调试任务,如在地址上设置断点。我说“在理论上”,因为如今调试存根变得越来越大。例如,我机器上的 LLDB 调试存根大小是 7.6MB。调试存根通过使用一些特定于操作系统的功能(在我们的例子中是 `ptrace`)和被调试进程以及通过远程协议的调试器通信。 -最常见的远程调试协议是 GDB 远程协议。这是一种基于文本的数据包格式,用于在调试器和 debug - stub 之间传递命令和信息。我不会详细介绍它,但你可以在[这里][11]阅读你想知道的。如果你启动 LLDB 并执行命令 `log enable gdb-remote packets`,那么你将获得通过远程协议发送的所有数据包的跟踪。在 GDB 上,你可以用 `set remotelogfile ` 做同样的事情。 +最常见的远程调试协议是 GDB 远程协议。这是一种基于文本的数据包格式,用于在调试器和调试存根之间传递命令和信息。我不会详细介绍它,但你可以在[这里][11]进一步阅读。如果你启动 LLDB 并执行命令 `log enable gdb-remote packets`,那么你将获得通过远程协议发送的所有数据包的跟踪信息。在 GDB 上,你可以用 `set remotelogfile ` 做同样的事情。 -作为一个简单的例子,这是数据包设置断点: +作为一个简单的例子,这是设置断点的数据包: ``` $Z0,400570,1#43 - ``` `$` 标记数据包的开始。`Z0` 是插入内存断点的命令。`400570` 和 `1` 是参数,其中前者是设置断点的地址,后者是特定目标的断点类型说明符。最后,`#43` 是校验值,以确保数据没有损坏。 GDB 远程协议非常易于扩展自定义数据包,这对于实现平台或语言特定的功能非常有用。 -* * * - ### 共享库和动态加载支持 -调试器需要知道调试程序加载了哪些共享库,以便它可以设置断点,获取源代码级别的信息和符号等。除查找被动态链接的库之外,调试器还必须跟踪在运行时通过 `dlopen` 加载的库。为了打到这个目的,动态链接器维护一个 _交会结构体_。该结构体维护共享描述符的链表以及指向每当更新链表时调用的函数的指针。这个结构存储在 ELF 文件的 `.dynamic` 段中,在程序执行之前被初始化。 +调试器需要知道被调试程序加载了哪些共享库,以便它可以设置断点、获取源代码级别的信息和符号等。除查找被动态链接的库之外,调试器还必须跟踪在运行时通过 `dlopen` 加载的库。为了达到这个目的,动态链接器维护一个 _交汇结构体_。该结构体维护共享库描述符的链表,以及一个指向每当更新链表时调用的函数的指针。这个结构存储在 ELF 文件的 `.dynamic` 段中,在程序执行之前被初始化。 一个简单的跟踪算法: -* 追踪程序在 ELF 头中查找程序的入口(或者可以使用存储在 `/proc//aux` 中的辅助向量) - +* 追踪程序在 ELF 头中查找程序的入口(或者可以使用存储在 `/proc//aux` 中的辅助向量)。 * 追踪程序在程序的入口处设置一个断点,并开始执行。 - * 当到达断点时,通过在 ELF 文件中查找 `.dynamic` 的加载地址找到交汇结构体的地址。 - * 检查交汇结构体以获取当前加载的库的列表。 - -* 链接器更新函数上设置断点 - -* 每当到达断点时,列表都会更新 - +* 链接器更新函数上设置断点。 +* 每当到达断点时,列表都会更新。 * 追踪程序无限循环,继续执行程序并等待信号,直到追踪程序信号退出。 我给这些概念写了一个小例子,你可以在[这里][12]找到。如果有人有兴趣,我可以将来写得更详细一点。 -* * * - ### 表达式计算 表达式计算是程序的一项功能,允许用户在调试程序时对原始源语言中的表达式进行计算。例如,在 LLDB 或 GDB 中,可以执行 `print foo()` 来调用 `foo` 函数并打印结果。 -根据表达的复杂程度,有几种不同的计算方法。如果表达式只是一个简单的标识符,那么调试器可以查看调试信息,找到变量并打印出该值,就像我们在本系列最后一部分中所做的那样。如果表达式有点复杂,则可能将代码编译成中间表达式 (IR) 并解释来获得结果。例如,对于某些表达式,LLDB 将使用 Clang 将表达式编译为 LLVM IR 并将其解释。如果表达式更复杂,或者需要调用某些函数,那么代码可能需要 JIT 到目标并在被调试者的地址空间中执行。这涉及到调用 `mmap` 来分配一些可执行内存,然后将编译的代码复制到该块并执行。LLDB 通过使用 LLVM 的 JIT 功能来实现。 +根据表达式的复杂程度,有几种不同的计算方法。如果表达式只是一个简单的标识符,那么调试器可以查看调试信息,找到该变量并打印出该值,就像我们在本系列最后一部分中所做的那样。如果表达式有点复杂,则可能将代码编译成中间表达式 (IR) 并解释来获得结果。例如,对于某些表达式,LLDB 将使用 Clang 将表达式编译为 LLVM IR 并将其解释。如果表达式更复杂,或者需要调用某些函数,那么代码可能需要 JIT 到目标并在被调试者的地址空间中执行。这涉及到调用 `mmap` 来分配一些可执行内存,然后将编译的代码复制到该块并执行。LLDB 通过使用 LLVM 的 JIT 功能来实现。 -如果你想更多地了解 JIT 编译,我强烈推荐[ Eli Bendersky 关于这个主题的文章][13]。 - -* * * +如果你想更多地了解 JIT 编译,我强烈推荐 [Eli Bendersky 关于这个主题的文章][13]。 ### 多线程调试支持 -本系列展示的调试器仅支持单线程应用程序,但是为了调试大多数真实程序,多线程支持是非常需要的。支持这一点的最简单的方法是跟踪线程创建并解析 procfs 以获取所需的信息。 +本系列展示的调试器仅支持单线程应用程序,但是为了调试大多数真实程序,多线程支持是非常需要的。支持这一点的最简单的方法是跟踪线程的创建,并解析 procfs 以获取所需的信息。 Linux 线程库称为 `pthreads`。当调用 `pthread_create` 时,库会使用 `clone` 系统调用来创建一个新的线程,我们可以用 `ptrace` 跟踪这个系统调用(假设你的内核早于 2.5.46)。为此,你需要在连接到调试器之后设置一些 `ptrace` 选项: @@ -97,7 +70,7 @@ Linux 线程库称为 `pthreads`。当调用 `pthread_create` 时,库会使用 ptrace(PTRACE_SETOPTIONS, m_pid, nullptr, PTRACE_O_TRACECLONE); ``` -现在当 `clone` 被调用时,该进程将收到我们的老朋友 `SIGTRAP` 发出信号。对于本系列中的调试器,你可以将一个例子添加到 `handle_sigtrap` 来处理新线程的创建: +现在当 `clone` 被调用时,该进程将收到我们的老朋友 `SIGTRAP` 信号。对于本系列中的调试器,你可以将一个例子添加到 `handle_sigtrap` 来处理新线程的创建: ``` case (SIGTRAP | (PTRACE_EVENT_CLONE << 8)): @@ -115,32 +88,30 @@ GDB 使用 `libthread_db`,它提供了一堆帮助函数,这样你就不需 多线程支持中最复杂的部分是调试器中线程状态的建模,特别是如果你希望支持[不间断模式][15]或当你计算中涉及不止一个 CPU 的某种异构调试。 -* * * - ### 最后! -呼!这个系列花了很长时间才写完,但是我在这个过程中学到了很多东西,我希望它是有帮助的。如果你聊有关调试或本系列中的任何问题,请在 Twitter [@TartanLlama][16]或评论区联系我。如果你有想看到的其他任何调试主题,让我知道我或许会再发其他的文章。 +呼!这个系列花了很长时间才写完,但是我在这个过程中学到了很多东西,我希望它是有帮助的。如果你有关于调试或本系列中的任何问题,请在 Twitter [@TartanLlama][16]或评论区联系我。如果你有想看到的其他任何调试主题,让我知道我或许会再发其他的文章。 -------------------------------------------------------------------------------- via: https://blog.tartanllama.xyz/writing-a-linux-debugger-advanced-topics/ -作者:[Simon Brand ][a] +作者:[Simon Brand][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://www.twitter.com/TartanLlama -[1]:https://blog.tartanllama.xyz/writing-a-linux-debugger-setup/ -[2]:https://blog.tartanllama.xyz/writing-a-linux-debugger-breakpoints/ -[3]:https://blog.tartanllama.xyz/writing-a-linux-debugger-registers/ -[4]:https://blog.tartanllama.xyz/writing-a-linux-debugger-elf-dwarf/ -[5]:https://blog.tartanllama.xyz/writing-a-linux-debugger-source-signal/ -[6]:https://blog.tartanllama.xyz/writing-a-linux-debugger-dwarf-step/ -[7]:https://blog.tartanllama.xyz/writing-a-linux-debugger-source-break/ -[8]:https://blog.tartanllama.xyz/writing-a-linux-debugger-unwinding/ -[9]:https://blog.tartanllama.xyz/writing-a-linux-debugger-variables/ +[1]:https://linux.cn/article-8626-1.html +[2]:https://linux.cn/article-8645-1.html +[3]:https://linux.cn/article-8663-1.html +[4]:https://linux.cn/article-8719-1.html +[5]:https://linux.cn/article-8812-1.html +[6]:https://linux.cn/article-8813-1.html +[7]:https://linux.cn/article-8890-1.html +[8]:https://linux.cn/article-8930-1.html +[9]:https://linux.cn/article-8936-1.html [10]:https://blog.tartanllama.xyz/writing-a-linux-debugger-advanced-topics/ [11]:https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html [12]:https://github.com/TartanLlama/dltrace From 4be6a454d36d5692869064bfc019117ccfc17f3c Mon Sep 17 00:00:00 2001 From: toutoudnf Date: Mon, 9 Oct 2017 00:24:26 +0800 Subject: [PATCH 014/485] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完成文章:20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH 的翻译 --- ... The 8 possible scenarios using OpenSSH.md | 436 ------------------ ... The 8 possible scenarios using OpenSSH.md | 412 +++++++++++++++++ 2 files changed, 412 insertions(+), 436 deletions(-) delete mode 100644 sources/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md create mode 100644 translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md diff --git a/sources/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md b/sources/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md deleted file mode 100644 index b96921df89..0000000000 --- a/sources/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md +++ /dev/null @@ -1,436 +0,0 @@ -【toutoudnf@gmail.com】翻译中 -Creating TCP / IP (port forwarding) tunnels with SSH: The 8 possible scenarios using OpenSSH -============================================================ - -The typical function of the [Secure Shell (SSH)][21] network protocol is to access a remote system in terminal mode and execute commands there safely, because the data is encrypted. In addition, through this secure data connection, it is possible to create tunnels (  _port forwarding_  ) between the connected ends so that the TCP / IP connections are channeled through the SSH connection so that we can get away with any Firewall or port blocking whenever we have the possibility to connect with SSH. - -As this topic is very much addressed by the entire network: - -* [Wikipedia: SSH Tunneling][12] - -* [O’Reilly: Using SSH Tunneling][13] - -* [Ssh.com: Tunneling Explained][14] - -* [Ssh.com: Port Forwarding][15] - -* [SecurityFocus: SSH Port Forwarding][16] - -* [Red Hat Magazine: SSH Port Forwarding][17] - -In this entry we will not go into the details of port forwarding, but pretend to be a  _cheat sheet_ , a quick reference (  _cheat sheet_  ) on how to forward TCP ports with [OpenSSH][22] in the 8 different scenarios that can be given. Other SSH clients such as [PuTTY][23] also allow port forwarding, but the configuration will be done with a graphical interface. We will focus on OpenSSH. - -In the following examples and situations we will assume that we have an external network and an internal network and between both networks, the only possible connection is an SSH connection between the node of the external external  _network1_  and the node of the internal internal  _network1_  . The  _external node2_  is on the external network and has full connectivity with  _external1_ . The node  _interno2_  is on the internal network and has full connectivity with  _interno1_ . - -![SSH tunnels: no tunnel](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_sin_tunel.png) - -Table of Contents [[hide][1]] - -* [1 Scenario 1: Use on external1 a TCP service offered by internal1 (Local port forwarding / bind_address = localhost / host = localhost)][2] - -* [2 Scenario 2: Use on external2 a TCP service offered by internal1 (Local port forwarding / bind_address = 0.0.0.0 / host = localhost)][3] - -* [3 Scenario 3: Use in internal1 a TCP service offered by external1 (Remote port forwarding / bind_address = localhost / host = localhost)][4] - -* [4 Scenario 4: Use in internal2 a TCP service offered by external1 (Remote port forwarding / bind_address = 0.0.0.0 / host = localhost)][5] - -* [5 Scenario 5: Use in external1 a TCP service offered by internal2 (Local port forwarding / bind_address = localhost / host = internal2)][6] - -* [6 Scenario 6: Use in internal1 a TCP service offered by external2 (Remote port forwarding / bind_address = localhost / host = external2)][7] - -* [7 Scenario 7: Use in external2 a TCP service offered by internal2 (Local port forwarding / bind_address = 0.0.0.0 / host = internal2)][8] - -* [8 Scenario 8: Use in internal2 a TCP service offered by external2 (Remote port forwarding / bind_address = 0.0.0.0 / host = external2)][9] - -#### Scenario 1: Use on  _external1_  a TCP service offered by  _internal1_  (Local port forwarding / bind_address = localhost / host = localhost) - -The system  _externo1_  can be connected to the system  _interno1 _ through OpenSSH and also wants to connect to the system server VNC (port 5900)  _interno1_ : - -![SSH Tunnels: Scenario 1](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_1.png) - -We will achieve this with this command: - -``` -External1 $ ssh -L 7900: localhost: 5900 user @ internal1 -``` - -Now in the  _external system1_  we can verify that port 7900 is waiting for connections: - -``` -External1 $ netstat -ltn -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State       -... -Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN   -... -``` - -We only need to execute now on  _external1_  : - -``` -External1 $ vncviewer localhost :: 7900 -``` - -To connect to the  _internal_  VNC  _server1_ . - -Note: This way to change the port is not documented in the  - -``` -man vncviewer -``` - -. Appears in: [About VNCViewer configuration of the output TCP port][18]. This is also how [the TightVNC vncviewer][19] does. - -#### Scenario 2: Use on  _external2_  a TCP service offered by  _internal1_  (Local port forwarding / bind_address = 0.0.0.0 / host = localhost) - -This time we start from a situation similar to the previous one but now we want it to be  _external2_  who connects to the  _internal_  VNC  _server1_ : - -![SSH Tunnels: Scenario 2](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_2.png) - -The appropriate command would be this: - -``` -External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 -``` - -It is similar to the first scenario; But in that, if we look at the output of  - -``` -netstat -``` - -the port, 7900 had been associated with the address of localhost, at 127.0.0.1, so only local processes could connect to it. This time we specify that the port is associated with 0.0.0.0, so that the system accepts connections to any local IP of the machine: - -``` -External1 $ netstat -ltn -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State       -... -Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN -... -``` - -So now, from  _external2_  , we can execute: - -``` -External2 $ vncviewer external1 :: 7900 -``` - -To connect to the  _internal_  VNC  _server1_ . - -Instead of specifying the IP  - -``` -0.0.0.0 -``` - -, we could also use the option  - -``` --g -``` - -(  _Allows remote hosts to connect to local forwarded ports_  ) like this: - -``` -External1 $ ssh -g -L 7900: localhost: 5900 user @ internal1 -``` - -With exactly the same result as the previous command: - -``` -External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 -``` - -On the other hand, if we had wanted to restrict the connection to only one of the local IPs of the system, we could have been more specific: - -``` -External1 $ ssh -L 192.168.24.80:7900:localhost:5900 user @ internal1 - -External1 $ netstat -ltn -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State -... -Tcp 0 0 192.168.24.80:7900 0.0.0.0:* LISTEN -... -``` - -#### Scenario 3: Use in  _internal1_  a TCP service offered by  _external1_  (Remote port forwarding / bind_address = localhost / host = localhost) - -In the first scenario, it was the system itself with the SSH server that offered another service. Now the system with the SSH client is the one that offers the service that the system with the SSH server wants to use: - -![SSH Tunnels: Scenario 3](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_3.png) - -The command we will use is the same as in the first scenario by changing the parameter  - -``` --L -``` - -to  - -``` --R -``` - -: - -``` -External1 $ ssh -R 7900: localhost: 5900 user @ internal1 -``` - - -And now where we will see that we have port 7900 listening is in  _interno1_ : - -``` -Internal1 $ netstat -lnt -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State -... -Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN -... -``` - -So now from  _internal1_  we can use the VNC server from  _external1_  like this: - -``` -Internal1 $ vncviewer localhost :: 7900 -``` - - -#### Scenario 4: Use in  _internal2_  a TCP service offered by  _external1_  (Remote port forwarding / bind_address = 0.0.0.0 / host = localhost) - -Similar to the third scenario but now, as we did in the second scenario, we will associate the forwarded port with the IP  - -``` -0.0.0.0 -``` - -so that other nodes can use the service: - -![SSH Tunnels: Scenario 4](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_4-1.png) - -The appropriate command is: - -``` -External1 $ ssh -R 0.0.0.0:7900:localhost:5900 user @ internal1 -``` - - -However, it is important to understand that, for security reasons, this will not work if in the configuration of the SSH server we do not modify the value of the parameter  - -``` -GatewayPorts -``` - - -that by default is  - -``` -no -``` - -: - -``` -GatewayPorts -``` - -> Specifies whether remote hosts are allowed to connect to ports forwarded for the client. By default, sshd(8) binds remote port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that sshd should allow remote port forwardings to bind to non-loopback addresses, thus allowing other hosts to connect. The argument may be “no” to force remote port forwardings to be available to the local host only, “yes” to force remote port forwardings to bind to the wildcard address, or “clientspecified” to allow the client to select the address to which the forwarding is bound. The default is “no”. - - - -If we do not have the possibility to modify the configuration of the server, we will not be able to use this type of port forwarding. At least not simply because, if there are no other impediments, a user can open a port (> 1024) to listen to external connections and forward that request to  - -``` -localhost:7900 -``` - - -. This could be done, for example, with [netcat][24] ( [Debian # 310431: sshd_config should warn about the GatewayPorts workaround.][25] ) - -So we  - -``` -/etc/ssh/sshd_config -``` - -will add: - -``` -GatewayPorts clientspecified -``` - - -After which we will have to reread the configuration with ”  - -``` -sudo /etc/init.d/ssh reload -``` - - -” (Debian and Ubuntu). - -We verify that  _internal1_  is listening for requests from all IPs: - -``` -Internal1 $ netstat -ltn -Active Internet connections (only servers) -Proto Recv-Q Send-Q Local Address Foreign Address State -... -Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN -... -``` - -And we can already use the VNC service from  _internal2_  : - -``` -Internal2 $ internal vncviewer1 :: 7900 -``` - - -#### Scenario 5: Use in  _external1_  a TCP service offered by  _internal2_  (Local port forwarding / bind_address = localhost / host = internal2) - -![SSH Tunnels: Scenario 5](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_5.png) - -In this scenario we will use the following command: - -``` -External1 $ ssh -L 7900: internal2: 5900 user @ internal1 -``` - -And we will access the service by running the command in  _external1_ : - -``` -External1 $ vncviewer localhost :: 7900 -``` - -#### Scenario 6: Use in  _internal1_  a TCP service offered by  _external2_  (Remote port forwarding / bind_address = localhost / host = external2) - -![SSH Tunnels: Scenario 6](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_6.png) - -In this scenario we will use the following command: - -``` -External1 $ ssh -R 7900: external2: 5900 user @ internal1 -``` - -And we will access the service by running the command in  _internal1_ : - -``` -Internal1 $ vncviewer localhost :: 7900 -``` - -#### Scenario 7: Use in  _external2_  a TCP service offered by  _internal2_  (Local port forwarding / bind_address = 0.0.0.0 / host = internal2) - -![SSH Tunnels: Scenario 7](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_7.png) - -In this scenario we will use the following command: - -``` -External1 $ ssh -L 0.0.0.0:7900:internal2:5900 user @ internal1 -``` - - -Or alternatively: - -``` -External1 $ ssh -g -L 7900: internal2: 5900 user @ internal1 -``` - - -And we will access the service by running the command in  _external2_  : - -``` -External2 $ vncviewer external1 :: 7900 -``` - -#### Scenario 8: Use in  _internal2_  a TCP service offered by  _external2_  (Remote port forwarding / bind_address = 0.0.0.0 / host = external2) - -![SSH Tunnels: Scenario 8](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_8.png) - -In this scenario we will use the following command: - -``` -External1 $ ssh -R 0.0.0.0:7900:external2:5900 user @ internal1 -``` - -The SSH server must be configured with ”  - -``` -GatewayPorts clientspecified -``` - -”, as we have seen in scenario 4. - -And we will access the service by running the command in  _internal2_ : - -``` -Internal2 $ internal vncviewer1 :: 7900 -``` - -If we want to create many tunnels at once, it may be convenient to use a configuration file instead of composing a very long command. Let’s imagine that our only entry point to a network is through SSH and we need to create tunnels to access the different servers in the network via SSH, VNC or [Remote Desktop][26]. We could compose a file like the following with all the redirects that we will need (in relation to the mentioned SOCKS server. - -``` -# SOCKS server -DynamicForward 1080 - -# SSH redirects -LocalForward 2221 serverlinux1: 22 -LocalForward 2222 serverlinux2: 22 -LocalForward 2223 172.16.23.45:22 -LocalForward 2224 172.16.23.48:22 - -# RDP redirects for Windows systems -LocalForward 3391 serverwindows1: 3389 -LocalForward 3392 serverwindows2: 3389 - -# VNC redirects for systems with "vncserver" -LocalForward 5902 serverlinux1: 5901 -LocalForward 5903 172.16.23.45:5901 -``` - - -And we only need to execute this to create all the redirects: - -``` -External1 $ ssh -F $ HOME / redirects user @ internal1 -``` - --------------------------------------------------------------------------------- - -via: https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/ - -作者:[ Ahmad][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://wesharethis.com/author/ahmad/ -[1]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/# -[2]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_1_Use_onexternal1a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_localhost_host_localhost -[3]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_2_Use_onexternal2a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_0000_host_localhost -[4]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_3_Use_ininternal1a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_localhost_host_localhost -[5]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_4_Use_ininternal2a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_0000_host_localhost -[6]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_5_Use_inexternal1a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_localhost_host_internal2 -[7]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_6_Use_ininternal1a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_localhost_host_external2 -[8]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_7_Use_inexternal2a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_0000_host_internal2 -[9]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_8_Use_ininternal2a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_0000_host_external2 -[10]:https://wesharethis.com/author/ahmad/ -[11]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#comments -[12]:http://en.wikipedia.org/wiki/Tunneling_protocol#SSH_tunneling -[13]:http://www.oreillynet.com/pub/a/wireless/2001/02/23/wep.html -[14]:http://www.ssh.com/support/documentation/online/ssh/winhelp/32/Tunneling_Explained.html -[15]:http://www.ssh.com/support/documentation/online/ssh/adminguide/32/Port_Forwarding.html -[16]:http://www.securityfocus.com/infocus/1816 -[17]:http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/ -[18]:http://www.realvnc.com/pipermail/vnc-list/2006-April/054551.html -[19]:http://www.tightvnc.com/vncviewer.1.html -[20]:https://bufferapp.com/add?url=https%3A%2F%2Fwesharethis.com%2F2017%2F07%2Fcreating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh%2F&text=Creating%20TCP%20/%20IP%20(port%20forwarding)%20tunnels%20with%20SSH:%20The%208%20possible%20scenarios%20using%20OpenSSH -[21]:http://en.wikipedia.org/wiki/Secure_Shell -[22]:http://www.openssh.com/ -[23]:http://www.chiark.greenend.org.uk/~sgtatham/putty/ -[24]:http://en.wikipedia.org/wiki/Netcat -[25]:http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=310431 -[26]:http://en.wikipedia.org/wiki/Remote_Desktop_Services diff --git a/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md b/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md new file mode 100644 index 0000000000..2df7a5f3c0 --- /dev/null +++ b/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md @@ -0,0 +1,412 @@ +通过 SSH 实现 TCP / IP 隧道(端口转发):使用 OpenSSH 可能的 8 种场景 +============================================================ + +对于 [Secure Shell (SSH)][21] 这样的网络协议来说,其主要职责就是在终端模式下访问一个远程系统。因为 SSH 协议对传输数据进行了加密,所以通过它在远端系统执行命令是非常安全的。此外,我们还可以在这种加密后的连接上通过创建隧道(端口转发)的方式,来实现两个不同终端间的互联。凭借这种方式,只要我们能通过 SSH 创建连接,就可以绕开防火墙或者端口禁用的限制。 + +这个话题在网络领域被广泛应用和讨论: + +* [Wikipedia: SSH Tunneling][12] + +* [O’Reilly: Using SSH Tunneling][13] + +* [Ssh.com: Tunneling Explained][14] + +* [Ssh.com: Port Forwarding][15] + +* [SecurityFocus: SSH Port Forwarding][16] + +* [Red Hat Magazine: SSH Port Forwarding][17] + +我们在接下来的内容中并不讨论端口转发的细节,而是准备介绍一个如何使用 [OpenSSH][22] 来完成 TCP 端口转发的速查表,其中包含了八种常见的场景。有些 SSH 客户端,比如 [PuTTY][23],也允许通过界面配置的方式来实现端口转发。而我们着重关注的是通过 OpenSSH 来实现的的方式。 + +在下面的例子当中,我们假设环境中的网络划分为外部网络(network1)和内部网络(network2)两部分,并且这两个网络之间,只能在 external1 与 internal1 之间通过 SSH 连接的方式来互相访问。外部网络的节点之间和内部网络的节点之间是完全联通的。 + +![SSH tunnels: no tunnel](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_sin_tunel.png) + +内容列表: + +* [1 场景 1 :在 external1 节点访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = localhost / 主机 = localhost )][2] + +* [2 场景 2:在 external2 节点上访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost)][3] + +* [3 场景 3:在 internal1 上访问由 external1 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / 主机 = localhost)][4] + +* [4 场景 4 :internal2 使用 external1 上提供的 TCP 服务(远端端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost)][5] + +* [5 场景 5 :在 external1 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 localhost / 主机 = internal2 )][6] + +* [6 场景 6 :在 internal1 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / host = external2)][7] + +* [7 场景7 :在 external2 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = internal2)][8] + +* [8 场景 8 : 在 internal2 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = 0.0.0.0 / 主机 = external2)][9] + +#### 场景 1 :在 external1 节点访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = localhost / 主机 = localhost ) + +externo1 节点可以通过 OpenSSH 连接到 interno1 节点,之后我们想通过其访问运行在 5900 端口上的 VNC 服务。 + +![SSH Tunnels: Scenario 1](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_1.png) + +我们可以通过下面的命令来实现: + +``` +External1 $ ssh -L 7900: localhost: 5900 user @ internal1 +``` + +现在,我们可以在 externo1 节点上确认下 7900 端口是否处于监听状态中: + +``` +External1 $ netstat -ltn +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State       +... +Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN   +... +``` + +我们只需要在 external1 节点上执行如下命令即可访问 internal 节点的 VNC 服务。: + +``` +External1 $ vncviewer localhost :: 7900 +``` + +注意:在下面的文档中并未提及这种修改端口号的方式。在[About VNCViewer configuration of the output TCP port][18] 中可以看到。这也是 [the TightVNC vncviewer][19] 所介绍的的。 + +``` +man vncviewer +``` + +#### 场景 2:在 external2 节点上访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) + +这次的场景跟方案 1 的场景的类似,但是我们这次想从 external2 节点来连接到 internal1 上的 VNC 服务: + +![SSH Tunnels: Scenario 2](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_2.png) + +正确的命令如下: + +``` +External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 +``` + +看起来跟方案 1 中的命令类似,但是让我们看看 netstat 命令的输出上的区别: + +``` +netstat +``` + +7900 端口被绑定到了本地(127.0.0.1),所以只有本地进程可以访问。这次我们将端口关联到了 0.0.0.0,所以系统允许任何 IP 地址的机器访问 7900 这个端口。 + +``` +External1 $ netstat -ltn +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State       +... +Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN +... +``` + +所以现在在 external2 节点上,我们可移执行: + +``` +External2 $ vncviewer external1 :: 7900 +``` + +来连接到 internal1 节点上的 VNC 服务。 + +除了将 IP 指定为 + +``` +0.0.0.0 +``` + +之外,我们还可以使用如下参数: + +``` +-g +``` + +(允许远程机器使用本地端口转发),完整命令如下: + +``` +External1 $ ssh -g -L 7900: localhost: 5900 user @ internal1 +``` + +这条命令与前面的命令能实现相同效果: + +``` +External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 +``` + +换句话说,如果我们想限制只有指定 IP 的机器才能访问转发端口,可以像下面这样定义: + +``` +External1 $ ssh -L 192.168.24.80:7900:localhost:5900 user @ internal1 + +External1 $ netstat -ltn +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State +... +Tcp 0 0 192.168.24.80:7900 0.0.0.0:* LISTEN +... +``` + +#### 场景 3:在 internal1 上访问由 external1 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / 主机 = localhost) + +在场景 1 中 SSH 服务器与 TCP 服务(VNC)提供者在同一个节点上。现在我们想在 SSH 客户端所在的节点上,提供一个 TCP 服务(VNC)供 SSH 服务端来访问: + +![SSH Tunnels: Scenario 3](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_3.png) + +将方案 1 中的命令参数由: + +``` +-L +``` + +替换为 + +``` +-R +``` + +完整命令如下: + +``` +External1 $ ssh -R 7900: localhost: 5900 user @ internal1 +``` + +然后我们就能看到 interno1 节点上对 7900 端口正在监听: + +``` +Internal1 $ netstat -lnt +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State +... +Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN +... +``` + +现在在 internal1 节点上,我们可以使用如下命令来访问 external1 上的 VNC 服务。 + +``` +Internal1 $ vncviewer localhost :: 7900 +``` + +#### 场景 4 :internal2 使用 external1 上提供的 TCP 服务(远端端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) + +与场景 3 类似,但是现在我们尝试指定允许访问转发端口的 IP(就像方案 2 中做的一样) + +``` +0.0.0.0 +``` + +这样其他节点也可以访问 VNC 服务: + +![SSH Tunnels: Scenario 4](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_4-1.png) + +正确的命令是: + +``` +External1 $ ssh -R 0.0.0.0:7900:localhost:5900 user @ internal1 +``` + +但是如果我们直接执行该命令的话可能不会生效,因为我们需要修改 SSH 服务端的一个参数值: + +``` +GatewayPorts +``` + +他的默认值是: + +``` +no +``` + +> GatewayPorts +> +> 该参数指定了是否允许远程主机访问转发端口。默认情况下,sshd(8) 只允许本机进程访问转发端口。这是为了阻止其他主机连接到该转发端口。GatewayPorts 参数可用于指定 sshd 允许哪些远程主机访问转发端口。当参数值设置为 “no” 的时候只有本机可以访问转发端口;“yes” 则表示允许符合远程主机 IP 地址通配符规则的远程主机访问该转发端口;“clientspecified” 则表示由客户端来选择哪些主机地址允许访问转发端口。默认值是 “no”。 + +如果我们没有修改服务器配置的权限,我们将不能使用该方案来进行端口转发。这是因为如果没有其他的限制,用户可以开启一个端口(> 1024)来监听来自外部的请求并转发到: + +``` +localhost:7900 +``` + +参照这个案例:[netcat][24] ( [Debian # 310431: sshd_config should warn about the GatewayPorts workaround.][25] ) + +所以我们修改: + +``` +/etc/ssh/sshd_config +``` + +添加如下内容: + +``` +GatewayPorts clientspecified +``` + +然后,我们使用如下命令来重载修改后的配置文件(在 Debian 和 Ubuntu 上)。 + +``` +sudo /etc/init.d/ssh reload +``` + +我们确认现在 internal1 节点上存在 7900 端口的监听程序,监听来自不同 IP 的请求: + +``` +Internal1 $ netstat -ltn +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State +... +Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN +... +``` + +然后我们就可以在 internal2 节点上使用 VNC 服务了: + +``` +Internal2 $ internal vncviewer1 :: 7900 +``` + +#### 场景 5 :在 external1 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 localhost / 主机 = internal2 ) + +![SSH Tunnels: Scenario 5](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_5.png) + +在这种场景下我们使用如下命令: + +``` +External1 $ ssh -L 7900: internal2: 5900 user @ internal1 +``` + +然后我们就能在 external1 节点上,通过执行如下命令来使用 VNC 服务了: + +``` +External1 $ vncviewer localhost :: 7900 +``` + +#### 场景 6 :在 internal1 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / host = external2) + +![SSH Tunnels: Scenario 6](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_6.png) + +在这种场景下,我们使用如下命令: + +``` +External1 $ ssh -R 7900: external2: 5900 user @ internal1 +``` + +然后我们可以在 internal1 上通过执行如下命令来访问 VNC 服务: + +``` +Internal1 $ vncviewer localhost :: 7900 +``` + +#### 场景7 :在 external2 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = internal2) + +![SSH Tunnels: Scenario 7](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_7.png) + +本场景下,我们使用如下命令: + +``` +External1 $ ssh -L 0.0.0.0:7900:internal2:5900 user @ internal1 +``` + +或者: + +``` +External1 $ ssh -g -L 7900: internal2: 5900 user @ internal1 +``` + +然后我们就可以在 external2 上执行如下命令来访问 vnc 服务: + +``` +External2 $ vncviewer external1 :: 7900 +``` + +#### 场景 8 : 在 internal2 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = 0.0.0.0 / 主机 = external2) + +![SSH Tunnels: Scenario 8](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_8.png) + +本场景下我们使用如下命令: + +``` +External1 $ ssh -R 0.0.0.0:7900:external2:5900 user @ internal1 +``` + +SSH 服务器需要配置为: + +``` +GatewayPorts clientspecified +``` + +就像我们在场景 4 中讲过的那样。 + +然后我们可以在 internal2 节点上执行如下命令来访问 VNC 服务: + +``` +Internal2 $ internal vncviewer1 :: 7900 +``` + +如果我们需要一次性的创建多个隧道,使用配置文件的方式替代一个可能很长的命令是一个更好的选择。假设我们只能通过 SSH 的方式访问某个特定网络,同时又需要创建多个隧道来访问该网络内不同服务器上的服务,比如 VNC 或者 [远程桌面][26]。此时只需要创建一个如下的配置文件即可(在 SOCKS 服务器 上)。 + +``` +# SOCKS server +DynamicForward 1080 + +# SSH redirects +LocalForward 2221 serverlinux1: 22 +LocalForward 2222 serverlinux2: 22 +LocalForward 2223 172.16.23.45:22 +LocalForward 2224 172.16.23.48:22 + +# RDP redirects for Windows systems +LocalForward 3391 serverwindows1: 3389 +LocalForward 3392 serverwindows2: 3389 + +# VNC redirects for systems with "vncserver" +LocalForward 5902 serverlinux1: 5901 +LocalForward 5903 172.16.23.45:5901 +``` + +然后我们只需要执行如下命令: + +``` +External1 $ ssh -F $ HOME / redirects user @ internal1 +``` + +-------------------------------------------------------------------------------- + +via: https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/ + +作者:[ Ahmad][a] +译者:[toutoudnf](https://github.com/toutoudnf) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://wesharethis.com/author/ahmad/ +[1]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/# +[2]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_1_Use_onexternal1a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_localhost_host_localhost +[3]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_2_Use_onexternal2a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_0000_host_localhost +[4]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_3_Use_ininternal1a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_localhost_host_localhost +[5]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_4_Use_ininternal2a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_0000_host_localhost +[6]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_5_Use_inexternal1a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_localhost_host_internal2 +[7]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_6_Use_ininternal1a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_localhost_host_external2 +[8]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_7_Use_inexternal2a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_0000_host_internal2 +[9]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_8_Use_ininternal2a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_0000_host_external2 +[10]:https://wesharethis.com/author/ahmad/ +[11]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#comments +[12]:http://en.wikipedia.org/wiki/Tunneling_protocol#SSH_tunneling +[13]:http://www.oreillynet.com/pub/a/wireless/2001/02/23/wep.html +[14]:http://www.ssh.com/support/documentation/online/ssh/winhelp/32/Tunneling_Explained.html +[15]:http://www.ssh.com/support/documentation/online/ssh/adminguide/32/Port_Forwarding.html +[16]:http://www.securityfocus.com/infocus/1816 +[17]:http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/ +[18]:http://www.realvnc.com/pipermail/vnc-list/2006-April/054551.html +[19]:http://www.tightvnc.com/vncviewer.1.html +[20]:https://bufferapp.com/add?url=https%3A%2F%2Fwesharethis.com%2F2017%2F07%2Fcreating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh%2F&text=Creating%20TCP%20/%20IP%20(port%20forwarding)%20tunnels%20with%20SSH:%20The%208%20possible%20scenarios%20using%20OpenSSH +[21]:http://en.wikipedia.org/wiki/Secure_Shell +[22]:http://www.openssh.com/ +[23]:http://www.chiark.greenend.org.uk/~sgtatham/putty/ +[24]:http://en.wikipedia.org/wiki/Netcat +[25]:http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=310431 +[26]:http://en.wikipedia.org/wiki/Remote_Desktop_Services From fda649e7fd99dcc6226b358cfec32a7dafb5bd48 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 9 Oct 2017 08:44:31 +0800 Subject: [PATCH 015/485] translating --- ...0170421 A Window Into the Linux Desktop.md | 103 ------------------ ...0170421 A Window Into the Linux Desktop.md | 100 +++++++++++++++++ 2 files changed, 100 insertions(+), 103 deletions(-) delete mode 100644 sources/talk/20170421 A Window Into the Linux Desktop.md create mode 100644 translated/talk/20170421 A Window Into the Linux Desktop.md diff --git a/sources/talk/20170421 A Window Into the Linux Desktop.md b/sources/talk/20170421 A Window Into the Linux Desktop.md deleted file mode 100644 index 2091ead8e8..0000000000 --- a/sources/talk/20170421 A Window Into the Linux Desktop.md +++ /dev/null @@ -1,103 +0,0 @@ -traslating---geekp - -A Window Into the Linux Desktop -============================================================ - -![linux-desktop](http://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) - -![](http://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) - -"What can it do that Windows can't?" - -That is the first question many people ask when considering Linux for their desktop. While the open source philosophy that underpins Linux is a good enough draw for some, others want to know just how different its look, feel and functionality can get. To a degree, that depends on whether you choose a desktop environment or a window manager. - -If you want a desktop experience that is lightning fast and uncompromisingly efficient, foregoing the classic desktop environment for a window manager might be for you. - -### What's What - -"Desktop environment" is the technical term for a typical, full-featured desktop -- that is, the complete graphical layout of your system. Besides displaying your programs, the desktop environment includes accoutrements such as app launchers, menu panels and widgets. - -In Microsoft Windows, the desktop environment consists of, among other things, the Start menu, the taskbar of open applications and notification center, all the Windows programs that come bundled with the OS, and the frames enclosing open applications (with a dash, square and X in the upper right corner). - -There are many similarities in Linux. - -The Linux [Gnome][3] desktop environment, for instance, has a slightly different design, but it shares all of the Microsoft Windows basics -- from an app menu to a panel showing open applications, to a notification bar, to the windows framing programs. - -Window program frames rely on a component for drawing them and letting you move and resize them: It's called the "window manager." So, as they all have windows, every desktop environment includes a window manager. - -However, not every window manager is part of a desktop environment. You can run window managers by themselves, and there are reasons to consider doing just that. - -### Out of Your Environment - -For the purpose of this column, references to "window manager" refer to those that can stand alone. If you install a window manager on an existing Linux system, you can log out without shutting down, choose the new window manager on your login screen, and log back in. - -You might not want to do this without researching your window manager first, though, because you will be greeted by a blank screen and sparse status bar that may or may not be clickable. - -There typically is a straightforward way to bring up a terminal in a window manager, because that's how you edit its configuration file. There you will find key- and mouse-bindings to launch programs, at which point you actually can use your new setup. - -In the popular i3 window manager, for instance, you can launch a terminal by hitting the Super (i.e., Windows) key plus Enter -- or press Super plus D to bring up the app launcher. There you can type an app name and hit Enter to open it. All the existing apps can be found that way, and they will open to full screen once selected. - - [![i3 window manager](http://www.linuxinsider.com/article_images/2017/84473_620x388-small.jpg)][4] (Click Image to Enlarge) - -i3 is also a tiling window manager, meaning it ensures that all windows expand to evenly fit the screen, neither overlapping nor wasting space. When a new window pops up, it reduces the existing windows, nudging them aside to make room. Users can toggle to open the next window either vertically or horizontally adjacent. - -### Features Can Be Friends or Foes - -Desktop environments have their advantages, of course. First and foremost, they provide a feature-rich, recognizable interface. Each has its signature style, but overall they provide unobtrusive default settings out of the box, which makes desktop environments ready to use right from the start. - -Another strong point is that desktop environments come with a constellation of programs and media codecs, allowing users to accomplish simple tasks immediately. Further, they include handy features like battery monitors, wireless widgets and system notifications. - -As comprehensive as desktop environments are, the large software base and user experience philosophy unique to each means there are limits on how far they can go. That means they are not always very configurable. With desktop environments that emphasize flashy looks, oftentimes what you see is what you get. - -Many desktop environments are notoriously heavy on system resources, so they're not friendly to lower-end hardware. Because of the visual effects running on them, there are more things that can go wrong, too. I once tried tweaking networking settings that were unrelated to the desktop environment I was running, and the whole thing crashed. When I started a window manager, I was able to change the settings. - -Those prioritizing security may want to avoid desktop environments, since more programs means greater attack surface -- that is, entry points where malicious actors can break in. - -However, if you want to give a desktop environment a try, XFCE is a good place to start, as its smaller software base trims some bloat, leaving less clutter behind if you don't stick with it. - -It's not the prettiest at first sight, but after downloading some GTK theme packs (every desktop environment serves up either these or Qt themes, and XFCE is in the GTK camp) and enabling them in the Appearance section of settings, you easily can touch it up. You can even shop around at this [centralized gallery][5] to find the theme you like best. - -### You Can Save a Lot of Time... if You Take the Time First - -If you'd like to see what you can do outside of a desktop environment, you'll find a window manager allows plenty of room to maneuver. - -More than anything, window managers are about customization. In fact, their customizability has spawned numerous galleries hosting a vibrant community of users whose palette of choice is a window manager. - -The modest resource needs of window managers make them ideal for lower specs, and since most window managers don't come with any programs, they allow users who appreciate modularity to add only those they want. - -Perhaps the most noticeable distinction from desktop environments is that window managers generally focus on efficiency by emphasizing mouse movements and keyboard hotkeys to open programs or launchers. - -Keyboard-driven window managers are especially streamlined, since you can bring up new windows, enter text or more keyboard commands, move them around, and close them again -- all without moving your hands from the home row. Once you acculturate to the design logic, you will be amazed at how quickly you can blaze through your tasks. - -In spite of the freedom they provide, window managers have their drawbacks. Most significantly, they are extremely bare-bones out of the box. Before you can make much use of one, you'll have to spend time reading your window manager's documentation for configuration syntax, and probably some more time getting the hang of said syntax. - -Although you will have some user programs if you switched from a desktop environment (the likeliest scenario), you also will start out missing familiar things like battery indicators and network widgets, and it will take some time to set up new ones. - -If you want to dive into window managers, i3 has [thorough documentation][6] and straightforward configuration syntax. The configuration file doesn't use any programming language -- it simply defines a variable-value pair on each line. Creating a hotkey is as easy as writing "bindsym", the key combination, and the action for that combination to launch. - -While window managers aren't for everyone, they offer a distinctive computing experience, and Linux is one of the few OSes that allows them. No matter which paradigm you ultimately go with, I hope this overview gives you enough information to feel confident about the choice you've made -- or confident enough to venture out of your familiar zone and see what else is available.  - --------------------------------------------------------------------------------- - -作者简介: - -**Jonathan Terrasi** has been an ECT News Network columnist since 2017\. His main interests are computer security (particularly with the Linux desktop), encryption, and analysis of politics and current affairs. He is a full-time freelance writer and musician. His background includes providing technical commentaries and analyses in articles published by the Chicago Committee to Defend the Bill of Rights. - - ------------ - -via: http://www.linuxinsider.com/story/84473.html?rss=1 - -作者:[ ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]:http://www.linuxinsider.com/story/84473.html?rss=1# -[2]:http://www.linuxinsider.com/perl/mailit/?id=84473 -[3]:http://en.wikipedia.org/wiki/GNOME -[4]:http://www.linuxinsider.com/article_images/2017/84473_1200x750.jpg -[5]:http://www.xfce-look.org/ -[6]:https://i3wm.org/docs/ diff --git a/translated/talk/20170421 A Window Into the Linux Desktop.md b/translated/talk/20170421 A Window Into the Linux Desktop.md new file mode 100644 index 0000000000..53d7e6f311 --- /dev/null +++ b/translated/talk/20170421 A Window Into the Linux Desktop.md @@ -0,0 +1,100 @@ +进入 Linux 桌面的窗口 +============================================================ + +![linux-desktop](http://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) + +![](http://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) + +“它能做什么 Windows 不能做的吗?” + +这是许多人在考虑使用 Linux 桌面时的第一个问题。虽然支撑 Linux 的开源哲学对于某些人来说就是一个很好的理由,但是一些人想知道它在外观、感受和功能上有多么不同。在某种程度上,这取决于你是否选择桌面环境或窗口管理器。 + +如果你想要的是闪电般快速的桌面体验且向高效妥协, 那么上述的经典桌面中的窗口管理器可能适合你。 + +### 什么是什么 + +“桌面环境”是典型的全功能桌面的技术术语,即系统的完整图形化布局。除了显示你的程序,桌面环境还包括应用程序启动器,菜单面板和小部件等。 + +在 Microsoft Windows 中,桌面环境包括开始菜单,打开的程序的任务栏和通知中心,还有与操作系统捆绑在一起的所有 Windows 程序,以及打开程序的框架(有破折号、正方形和右上角的 X)。 + +Linux 中有很多相似之处。 + +例如,Linux [Gnome][3] 桌面环境的设计略有不同,但它共享了所有的 Microsoft Windows 的基本 - 从应用程序菜单到显示打开的应用程序的面板、通知栏、窗口框架程序。 + +窗口程序框架依赖于一个组件来绘制它们,并允许你移动并调整大小:它被称为“窗口管理器”。因为它们都有窗口,每个桌面环境都包含一个窗口管理器。 + +然而,并不是每个窗口管理器都是桌面环境的一部分。你可以只运行窗口管理器,并且有理由考虑这么做。 + +### 离开你的环境 + +在本专栏中,对“窗口管理器”的引用指的是可以独立进行的。如果在现有的 Linux 系统上安装了一个窗口管理器,你可以在不关闭的情况下注销,在登录屏幕上选择新的窗口管理器,然后重新登录。 + +不过, 在研究你的窗口管理器之前,你可能不想这么做,因为你会看到空白屏幕和稀疏的状态栏,这可能可以或不可以点击的。 + +通常情况下,可以直接在窗口管理器中启动终端,因为这是你编辑其配置文件的方式。在那里你会发现按键和鼠标绑定来启动程序,此时你实际上可以使用你的新设置。 + +例如,在流行的 i3 窗口管理器中,你可以通过按下 Super(即 Windows)键加 Enter 键来启动终端,或者按 Super + D 启动应用程序启动器。你可以在其中输入应用程序名称,然后按 Enter 键将其打开。所有现有的应用程序都可以通过这种方式找到,一旦选择后,它们将会全屏打开。 + + [![i3 window manager](http://www.linuxinsider.com/article_images/2017/84473_620x388-small.jpg)][4] (Click Image to Enlarge) + +i3 还是一个平铺的窗口管理器,这意味着它可以确保所有的窗口均匀地扩展到屏幕,既不重叠也不浪费空间。当弹出新窗口时,它会减少现有的窗口,将它们推到一边腾出空间。用户可以以垂直或水平的方式切换到相邻的窗口打开。 + +### 功能可以是朋友或敌人 + +当然,桌面环境有其优点。首先,它们提供功能丰富,可识别的界面。每个都有其签名风格,但总体而言,它们提供了不引人注目的默认设置,这使得桌面环境从一开始就可以使用。 + +另一个优点是桌面环境有一组程序和媒体编解码器,允许用户立即完成简单的任务。此外,它们还包括便携式功能,如电池监视器、无线小部件和系统通知。 + +如桌面环境一样完善,大型软件基础和用户体验理念独一无二,这就意味着它们能走多远都是有限度的。这意味着它们并不总是非常可配置。桌面环境强调的是漂亮的外表,很多时候你所见并不是你所得的。 + +许多桌面环境对系统资源的要求是众所周知的,所以它们对低端硬件不友善。因为在它们身上运行的视觉效果,还有更多的事情可能会出错。我曾经尝试调整与我正在运行的桌面环境无关的网络设置,但系统崩溃了。当我打开一个窗口管理器,我就可以改变设置。 + +那些优先考虑安全性的人可能希望避免桌面环境,因为更多的程序意味着更大的攻击面 - 也就是恶意角色可以突破的入口点。 + +然而,如果你想尝试一下桌面环境,XFCE 是一个很好的开始,因为它的较小的软件基础删除了一些膨胀,如果你不坚持使用,可以留下更少的混乱。 + +乍一看,它不是最漂亮的,但在下载了一些 GTK 主题包(每个桌面环境都可以提供这些或 Qt 主题,XFCE 在 GTK 阵营中),并且在“外观”部分的设置中,你可以轻松地修改。你甚至可以在这个[集中式画廊][5]中找到你最喜欢的主题。 + +### 你可以节省大量的时间..如果你把时间放在第一位 + +如果你想了解桌面环境之外可以做什么,你会发现窗口管理器有足够的空间来操纵。 + +无论如何,窗口管理器都是关于定制的。事实上,它们的可定制性已经催生了无数的画廊, 承载着一个充满活力的社区用户,他们选择的调色板是窗口管理器。 + +窗口管理器的少量资源需求使它们成为较低规格硬件的理想选择,并且由于大多数窗口管理器不附带任何程序,因此允许喜欢模块化的用户只添加所需的程序。 + +与桌面环境最为显著的区别可能是,窗口管理器通常通过鼠标移动和键盘热键来打开程序或启动器来聚焦效率。 + +键盘驱动的窗口管理器特别精简,因为你可以启动新的窗口、输入文本或更多的键盘命令、移动它们,并再次关闭它们,这一切无需将手从主页移开。一旦你符合设计逻辑,你会惊讶于你能够快速地完成任务。 + +尽管它们提供了自由,窗口管理器也有其缺点。最显著的是,它们是赤裸裸的开箱即用。在你可以使用其中一个之前,你必须花时间阅读窗口管理器的文档以获取配置语法,可能还需要更多的时间来获取所说语法的窍门。 + +如果你从桌面环境(最可能的情况)切换过来,尽管你会有一些用户程序,你也将缺少熟悉的东西,如电池指示器和网络小部件,并且需要一些时间来设置新的。 + +如果你想深入窗口管理器,i3 有[完整的文档][6]和简单的配置语法。配置文件不使用任何编程语言 - 它只是在每行上定义一个变量值对。创建热键只要输入 “bindsym”,它是键盘绑定以及该组合启动的动作。 + +虽然窗口管理器不适合每个人,但它们提供独特的计算体验,而 Linux 是少数允许使用的操作系统之一。无论你最终采用哪种模式,我希望这个概述能够给你足够的信息,以便对你所做的选择感到自信 - 或者有足够的信心跨出您熟悉的区域来看看还有什么可用的。 + +-------------------------------------------------------------------------------- + +作者简介: + +** Jonathan Terrasi ** 自 2017 年以来一直是 ECT 新闻网专栏作家。他的主要兴趣是计算机安全(特别是 Linux 桌面)、加密和分析政治和时事。他是全职自由作家和音乐家。他的背景包括在芝加哥委员会发表的关于维护人权法案的文章中提供技术评论和分析。 + +----------- + +via: http://www.linuxinsider.com/story/84473.html?rss=1 + +作者:[ ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]:http://www.linuxinsider.com/story/84473.html?rss=1# +[2]:http://www.linuxinsider.com/perl/mailit/?id=84473 +[3]:http://en.wikipedia.org/wiki/GNOME +[4]:http://www.linuxinsider.com/article_images/2017/84473_1200x750.jpg +[5]:http://www.xfce-look.org/ +[6]:https://i3wm.org/docs/ From 253e25c556f5843b0772f31892f469f2fd74ba3b Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 9 Oct 2017 08:48:30 +0800 Subject: [PATCH 016/485] translating --- sources/tech/20170617 What all you need to know about HTML5.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170617 What all you need to know about HTML5.md b/sources/tech/20170617 What all you need to know about HTML5.md index b5adee5fb2..fb366a77de 100644 --- a/sources/tech/20170617 What all you need to know about HTML5.md +++ b/sources/tech/20170617 What all you need to know about HTML5.md @@ -1,3 +1,5 @@ +translating---geekpi + What all you need to know about HTML5 ============================================================ From a7f376b56871677c2caac7bbc5456d682a5c0472 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Oct 2017 10:47:19 +0800 Subject: [PATCH 017/485] PRF:20170421 A Window Into the Linux Desktop.md @geekpi --- ...0170421 A Window Into the Linux Desktop.md | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/translated/talk/20170421 A Window Into the Linux Desktop.md b/translated/talk/20170421 A Window Into the Linux Desktop.md index 53d7e6f311..6a3d50f3f0 100644 --- a/translated/talk/20170421 A Window Into the Linux Desktop.md +++ b/translated/talk/20170421 A Window Into the Linux Desktop.md @@ -1,93 +1,91 @@ -进入 Linux 桌面的窗口 +进入 Linux 桌面之窗 ============================================================ ![linux-desktop](http://www.linuxinsider.com/article_images/story_graphics_xlarge/xl-2016-linux-1.jpg) -![](http://www.linuxinsider.com/images/2015/image-credit-adobe-stock_130x15.gif) +> “它能做什么 Windows 不能做的吗?” -“它能做什么 Windows 不能做的吗?” - -这是许多人在考虑使用 Linux 桌面时的第一个问题。虽然支撑 Linux 的开源哲学对于某些人来说就是一个很好的理由,但是一些人想知道它在外观、感受和功能上有多么不同。在某种程度上,这取决于你是否选择桌面环境或窗口管理器。 +这是许多人在考虑使用 Linux 桌面时的第一个问题。虽然支撑 Linux 的开源哲学对于某些人来说就是一个很好的理由,但是有些人想知道它在外观、感受和功能上有多么不同。在某种程度上,这取决于你是否选择桌面环境或窗口管理器。 如果你想要的是闪电般快速的桌面体验且向高效妥协, 那么上述的经典桌面中的窗口管理器可能适合你。 -### 什么是什么 +### 事实之真相 -“桌面环境”是典型的全功能桌面的技术术语,即系统的完整图形化布局。除了显示你的程序,桌面环境还包括应用程序启动器,菜单面板和小部件等。 +“桌面环境Desktop Environment(DE)”是一个技术术语,指典型的、全功能桌面,即你的操作系统的完整图形化布局。除了显示你的程序,桌面环境还包括应用程序启动器,菜单面板和小部件等组成部分。 -在 Microsoft Windows 中,桌面环境包括开始菜单,打开的程序的任务栏和通知中心,还有与操作系统捆绑在一起的所有 Windows 程序,以及打开程序的框架(有破折号、正方形和右上角的 X)。 +在 Microsoft Windows 中,桌面环境包括开始菜单、显示打开的程序的任务栏和通知中心,还有与操作系统捆绑在一起的所有 Windows 程序,以及围绕这打开的程序的框架(包括右上角的最小按钮、最大按钮和关闭按钮)。 Linux 中有很多相似之处。 -例如,Linux [Gnome][3] 桌面环境的设计略有不同,但它共享了所有的 Microsoft Windows 的基本 - 从应用程序菜单到显示打开的应用程序的面板、通知栏、窗口框架程序。 +例如,Linux [Gnome][3] 桌面环境的设计略有不同,但它共享了所有的 Microsoft Windows 的基本元素 - 从应用程序菜单到显示打开的应用程序的面板、通知栏、窗框式程序。 -窗口程序框架依赖于一个组件来绘制它们,并允许你移动并调整大小:它被称为“窗口管理器”。因为它们都有窗口,每个桌面环境都包含一个窗口管理器。 +窗口程序框架依赖于一个组件来绘制它们,并允许你移动并调整大小:它被称为“窗口管理器Window Manager(WM)”。因为它们都有窗口,所以每个桌面环境都包含一个窗口管理器。 -然而,并不是每个窗口管理器都是桌面环境的一部分。你可以只运行窗口管理器,并且有理由考虑这么做。 +然而,并不是每个窗口管理器都是桌面环境的一部分。你可以只运行窗口管理器,并且完全有这么做的需要。 ### 离开你的环境 -在本专栏中,对“窗口管理器”的引用指的是可以独立进行的。如果在现有的 Linux 系统上安装了一个窗口管理器,你可以在不关闭的情况下注销,在登录屏幕上选择新的窗口管理器,然后重新登录。 +对本专栏而言,所谓的“窗口管理器”指的是可以那种独立进行的。如果在现有的 Linux 系统上安装了一个窗口管理器,你可以在不关闭系统的情况下注销,在登录屏幕上选择新的窗口管理器,然后重新登录。 -不过, 在研究你的窗口管理器之前,你可能不想这么做,因为你会看到空白屏幕和稀疏的状态栏,这可能可以或不可以点击的。 +不过, 在研究你的窗口管理器之前,你可能不想这么做,因为你将会看到一个空白屏幕和稀疏的状态栏,而且它或许能、或许不能点击。 -通常情况下,可以直接在窗口管理器中启动终端,因为这是你编辑其配置文件的方式。在那里你会发现按键和鼠标绑定来启动程序,此时你实际上可以使用你的新设置。 +通常情况下,可以直接在窗口管理器中直接启动终端,因为这是你编辑其配置文件的方式。在那里你会发现用来启动程序的按键和鼠标组合,你实际上也可以使用你的新设置。 -例如,在流行的 i3 窗口管理器中,你可以通过按下 Super(即 Windows)键加 Enter 键来启动终端,或者按 Super + D 启动应用程序启动器。你可以在其中输入应用程序名称,然后按 Enter 键将其打开。所有现有的应用程序都可以通过这种方式找到,一旦选择后,它们将会全屏打开。 +例如,在流行的 i3 窗口管理器中,你可以通过按下 `Super` 键(即 `Windows` 键)加 `Enter` 键来启动终端,或者按 `Super + D` 启动应用程序启动器app launcher。你可以在其中输入应用程序名称,然后按 `Enter` 键将其打开。所有已有的应用程序都可以通过这种方式找到,一旦选择后,它们将会全屏打开。 - [![i3 window manager](http://www.linuxinsider.com/article_images/2017/84473_620x388-small.jpg)][4] (Click Image to Enlarge) + [![i3 window manager](http://www.linuxinsider.com/article_images/2017/84473_620x388-small.jpg)][4] -i3 还是一个平铺的窗口管理器,这意味着它可以确保所有的窗口均匀地扩展到屏幕,既不重叠也不浪费空间。当弹出新窗口时,它会减少现有的窗口,将它们推到一边腾出空间。用户可以以垂直或水平的方式切换到相邻的窗口打开。 +i3 还是一个平铺式窗口管理器,这意味着它可以确保所有的窗口均匀地扩展到屏幕,既不重叠也不浪费空间。当弹出新窗口时,它会减少现有的窗口,将它们推到一边腾出空间。用户可以以垂直或水平相邻的方式打开下一个窗口。 -### 功能可以是朋友或敌人 +### 功能亦敌亦友 -当然,桌面环境有其优点。首先,它们提供功能丰富,可识别的界面。每个都有其签名风格,但总体而言,它们提供了不引人注目的默认设置,这使得桌面环境从一开始就可以使用。 +当然,桌面环境有其优点。首先,它们提供功能丰富、可识别的界面。每个都有其特征鲜明的风格,但总体而言,它们提供了普适的默认设置,这使得桌面环境从一开始就可以使用。 -另一个优点是桌面环境有一组程序和媒体编解码器,允许用户立即完成简单的任务。此外,它们还包括便携式功能,如电池监视器、无线小部件和系统通知。 +另一个优点是桌面环境带有一组程序和媒体编解码器,允许用户立即完成简单的任务。此外,它们还包括一些方便的功能,如电池监视器、无线小部件和系统通知。 -如桌面环境一样完善,大型软件基础和用户体验理念独一无二,这就意味着它们能走多远都是有限度的。这意味着它们并不总是非常可配置。桌面环境强调的是漂亮的外表,很多时候你所见并不是你所得的。 +与桌面环境的完善相应的,是这种大型软件库和用户体验理念独一无二,这就意味着它们所能做的都是有限度的。这也意味着它们并不总是非常可配置。桌面环境强调的是漂亮的外表,很多时候是金玉其外的。 -许多桌面环境对系统资源的要求是众所周知的,所以它们对低端硬件不友善。因为在它们身上运行的视觉效果,还有更多的事情可能会出错。我曾经尝试调整与我正在运行的桌面环境无关的网络设置,但系统崩溃了。当我打开一个窗口管理器,我就可以改变设置。 +许多桌面环境对系统资源的渴求是众所周知的,所以它们不太喜欢低端硬件。因为在其上运行的视觉效果,还有更多的东西可能会出错。我曾经尝试调整与我正在运行的桌面环境无关的网络设置,然后整个崩溃了。而当我打开一个窗口管理器,我就可以改变设置。 -那些优先考虑安全性的人可能希望避免桌面环境,因为更多的程序意味着更大的攻击面 - 也就是恶意角色可以突破的入口点。 +那些优先考虑安全性的人可能希望不要桌面环境,因为更多的程序意味着更大的攻击面 —— 也就是坏人可以突破的入口点。 -然而,如果你想尝试一下桌面环境,XFCE 是一个很好的开始,因为它的较小的软件基础删除了一些膨胀,如果你不坚持使用,可以留下更少的混乱。 +然而,如果你想尝试一下桌面环境,XFCE 是一个很好的起点,因为它的较小的软件库消除了一些臃肿,如果你不往里面塞东西,垃圾就会更少。 -乍一看,它不是最漂亮的,但在下载了一些 GTK 主题包(每个桌面环境都可以提供这些或 Qt 主题,XFCE 在 GTK 阵营中),并且在“外观”部分的设置中,你可以轻松地修改。你甚至可以在这个[集中式画廊][5]中找到你最喜欢的主题。 +乍一看,它不是最漂亮的,但在下载了一些 GTK 主题包(每个桌面环境都可以提供这些主题或 Qt 主题,而 XFCE 在 GTK 阵营之中),并且在“外观”部分的设置中,你可以轻松地修改。你甚至可以在这个[集中式画廊][5]中找到你最喜欢的主题。 -### 你可以节省大量的时间..如果你把时间放在第一位 +### 时间就是生命 -如果你想了解桌面环境之外可以做什么,你会发现窗口管理器有足够的空间来操纵。 +如果你想了解桌面环境之外可以做什么,你会发现窗口管理器给了你足够的回旋余地。 -无论如何,窗口管理器都是关于定制的。事实上,它们的可定制性已经催生了无数的画廊, 承载着一个充满活力的社区用户,他们选择的调色板是窗口管理器。 +无论如何,窗口管理器都是与定制有关的。事实上,它们的可定制性已经催生了无数的画廊,承载着一个充满活力的社区用户,他们手中的调色板就是窗口管理器。 窗口管理器的少量资源需求使它们成为较低规格硬件的理想选择,并且由于大多数窗口管理器不附带任何程序,因此允许喜欢模块化的用户只添加所需的程序。 -与桌面环境最为显著的区别可能是,窗口管理器通常通过鼠标移动和键盘热键来打开程序或启动器来聚焦效率。 +可能与桌面环境最为显著的区别是,窗口管理器通常通过鼠标移动和键盘热键来打开程序或启动器来聚焦效率。 -键盘驱动的窗口管理器特别精简,因为你可以启动新的窗口、输入文本或更多的键盘命令、移动它们,并再次关闭它们,这一切无需将手从主页移开。一旦你符合设计逻辑,你会惊讶于你能够快速地完成任务。 +键盘驱动的窗口管理器特别流畅,你可以启动新的窗口、输入文本或更多的键盘命令、移动它们,并再次关闭它们,这一切无需将手从键盘中间home row移开。一旦你适应了其设计逻辑,你会惊讶于你能够如此快速地完成任务。 -尽管它们提供了自由,窗口管理器也有其缺点。最显著的是,它们是赤裸裸的开箱即用。在你可以使用其中一个之前,你必须花时间阅读窗口管理器的文档以获取配置语法,可能还需要更多的时间来获取所说语法的窍门。 +尽管它们提供了自由,窗口管理器也有其缺点。最显著的是,它们是赤裸裸的开箱即用。在你可以使用其中一个之前,你必须花时间阅读窗口管理器的文档以获取配置语法,可能还需要更多的时间来找到该语法的窍门。 -如果你从桌面环境(最可能的情况)切换过来,尽管你会有一些用户程序,你也将缺少熟悉的东西,如电池指示器和网络小部件,并且需要一些时间来设置新的。 +如果你从桌面环境(这是最可能的情况)切换过来,尽管你会有一些用户程序,你也会缺少一些熟悉的东西,如电池指示器和网络小部件,并且需要一些时间来设置新的。 -如果你想深入窗口管理器,i3 有[完整的文档][6]和简单的配置语法。配置文件不使用任何编程语言 - 它只是在每行上定义一个变量值对。创建热键只要输入 “bindsym”,它是键盘绑定以及该组合启动的动作。 +如果你想深入窗口管理器,i3 有[完整的文档][6]和简明直白的配置语法。配置文件不使用任何编程语言 - 它只是每行定义一个变量值对。创建热键只要输入 `bindsym`、键盘绑定以及该组合启动的动作即可。 -虽然窗口管理器不适合每个人,但它们提供独特的计算体验,而 Linux 是少数允许使用的操作系统之一。无论你最终采用哪种模式,我希望这个概述能够给你足够的信息,以便对你所做的选择感到自信 - 或者有足够的信心跨出您熟悉的区域来看看还有什么可用的。 +虽然窗口管理器不适合每个人,但它们提供了独特的计算体验,而 Linux 是少数允许使用它们的操作系统之一。无论你最终采用哪种模式,我希望这个概观能够给你足够的信息,以便对你所做的选择感到自信 —— 或者有足够的信心跨出您熟悉的区域来看看还有什么可用的。 -------------------------------------------------------------------------------- 作者简介: -** Jonathan Terrasi ** 自 2017 年以来一直是 ECT 新闻网专栏作家。他的主要兴趣是计算机安全(特别是 Linux 桌面)、加密和分析政治和时事。他是全职自由作家和音乐家。他的背景包括在芝加哥委员会发表的关于维护人权法案的文章中提供技术评论和分析。 +Jonathan Terrasi - 自 2017 年以来一直是 ECT 新闻网专栏作家。他的主要兴趣是计算机安全(特别是 Linux 桌面)、加密和分析政治和时事。他是全职自由作家和音乐家。他的背景包括在芝加哥委员会发表的关于维护人权法案的文章中提供技术评论和分析。 ----------- -via: http://www.linuxinsider.com/story/84473.html?rss=1 +via: http://www.linuxinsider.com/story/84473.html -作者:[ ][a] +作者:[Jonathan Terrasi][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 7f9834a0a1f0dd8d1b5e529621778dd72512c099 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Oct 2017 10:47:41 +0800 Subject: [PATCH 018/485] PUB:20170421 A Window Into the Linux Desktop.md @geekpi https://linux.cn/article-8944-1.html --- .../20170421 A Window Into the Linux Desktop.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20170421 A Window Into the Linux Desktop.md (100%) diff --git a/translated/talk/20170421 A Window Into the Linux Desktop.md b/published/20170421 A Window Into the Linux Desktop.md similarity index 100% rename from translated/talk/20170421 A Window Into the Linux Desktop.md rename to published/20170421 A Window Into the Linux Desktop.md From f7acae09363d4d52ed737034ba09726525e568ff Mon Sep 17 00:00:00 2001 From: softpaopao Date: Mon, 9 Oct 2017 17:28:12 +0800 Subject: [PATCH 019/485] translated by softpaopao MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成,在第9节后边的内容不是太好懂。 --- ...9 12 cool things you can do with GitHub.md | 246 +++++++++--------- 1 file changed, 124 insertions(+), 122 deletions(-) diff --git a/sources/tech/20170909 12 cool things you can do with GitHub.md b/sources/tech/20170909 12 cool things you can do with GitHub.md index 15aeeae27f..dcdb56ba16 100644 --- a/sources/tech/20170909 12 cool things you can do with GitHub.md +++ b/sources/tech/20170909 12 cool things you can do with GitHub.md @@ -1,124 +1,124 @@ -12 cool things you can do with GitHub +12 件可以用 GitHub 完成的很酷的事情 ============================================================ -translating by softpaopao -I can’t for the life of me think of an intro, so… +我不能为我的人生想出一个引子来,所以... -### #1 Edit code on GitHub.com +### #1 在 GitHub.com 上编辑代码 -I’m going to start with one that I  _think_  most people know (even though I didn’t know until a week ago). +我想我要开始的第一件事是多数人都已经知道的(尽管一周之前的我并不知道)。 -When you’re in GitHub, looking at a file (any text file, any repository), there’s a little pencil up in the top right. If you click it, you can edit the file. When you’re done, hit Propose file change and GitHub will fork the repo for you and create a pull request. +当你登录到 GitHub ,查看一个文件时(任何文本文件,任何版本库),右上方会有一只小铅笔。点击它,你就可以编辑文件了。 当你编辑完成后,GitHub 会给出文件变更的建议然后为你 fork 你的仓库并创建一个 pull 请求。 -Isn’t that wild? It creates the fork for you! - -No need to fork and pull and change locally and push and create a PR. +是不是很疯狂?它为你创建了 fork ! +不需要去 fork ,pull ,本地更改,push 然后创建一个 PR。 ![](https://cdn-images-1.medium.com/max/1600/1*w3yKOnVwomvK-gc7hlQNow.png) -Not a real PR -This is great for fixing typos and a somewhat terrible idea for editing code. +不是一个真正的 PR -### #2 Pasting images +这对于修改错误的拼写以及编辑代码时的一些糟糕的想法是很有用的。 -You’re not just limited to text in comments and issue descriptions. Did you know you can paste an image straight from the clipboard? When you paste, you’ll see it gets uploaded (to the ‘cloud’, no doubt) and becomes the markdown for showing an image. +### #2 粘贴图像 -Neat. +在评论和 issue 的描述中并不仅限于使用文字。你知道你可以直接从剪切板粘贴图像吗? 在你粘贴的时候,你会看到图片被上传 (到云端,这毫无疑问)并转换成 markdown 显示的图片格式。 -### #3 Formatting code +整洁。 -If you want to write a code block, you can start with three backticks — just like you learned when you read the [Mastering Markdown][3] page — and GitHub will make an attempt to guess what language you’re writing. +### #3 格式化代码 -But if you’re posting a snippet of something like Vue, Typescript or JSX, you can specify that explicitly to get the right highlighting. +如果你想写一个代码块的话,你可以用三个反引号作为开始 —— 就像你在浏览 [熟练掌握 Markdown][3] 页面所学的一样 —— 而且 GitHub 会尝试去推测你所写下的语言。 -Note the ````jsx` on the first line here: +但如果你张贴像是 Vue ,Typescript 或 JSX 这样的代码,你就需要明确指出才能获得高亮显示。 + +在首行注明 ````jsx`: ![](https://cdn-images-1.medium.com/max/1600/1*xnt83oGWLtJzNzwp-YvSuA.png) -…which means the snippet is rendered correctly: +…这意味着代码段已经正确的呈现: ![](https://cdn-images-1.medium.com/max/1600/1*FnOcz-bZi3S9Tn3dDGiIbQ.png) -(This extends to gists, by the way. If you give a gist the extension of `.jsx`you’ll get JSX syntax highlighting.) +(顺便说一下,这些用法可以扩展到 gists。 如果你在 gist 中给出 `.jsx` 扩展,你的 JSX 语法就会高亮显示。) -Here’s a list of [all the supported syntaxes][4]. +这里是[所有被支持的语法][4]的清单。 -### #4 Closing issues with magic words in PRs +### #4 用 PRs 中的魔法词来关闭 issues -Let’s say you’re creating a pull request that fixes issue #234\. You can put the text “fixes #234” in the description of your PR (or indeed anywhere in any comment on the PR). +比方说你已经创建了一个 pull 请求用来修复 issue #234 。那么你就可以把 “fixes #234” 这段文字放在你的 PR 描述中(或者是在 PR 的评论的任何位置)。 -Then, merging the PR automagically closes that issue. Isn’t that cool? +接下来,在合并 PR 时会自动关闭与之对应的问题。这是不是很酷? -There’s [more to learn in the help][5]. +这里是[更详细的学习帮助][5]。 -### #5 Linking to comments +### #5 链接到评论 -Have you even wanted to link to a particular comment but couldn’t work out how? That’s because you don’t know how to do it. But those days are behind you my friend, because I am here to tell you that clicking on the date/time next to the name is how you link to a comment. +是否你曾经想要链接到一个特定的评论但却不知道该怎么做?这是因为你不知道如何去做到这些。但那都将是过去了我的朋友,因为我在这里告诉你,点击紧挨着名字的日期或时间,这就是如何链接到一个评论。 ![](https://cdn-images-1.medium.com/max/1600/1*rSq4W-utQGga5GOW-w2QGg.png) -Hey, gaearon got a picture! -### #6 Linking to code +嘿,这里有 gaearon 的照片! -So you want to link to a specific line of code. I get that. +### #6 链接到代码 -Try this: while looking at the file, click the line number next to said code. +那么你想要链接到代码的特定行。我明白。 -Whoa, did you see that? The URL was updated with the line number! If you hold down shift and click another line number, SHAZAAM, the URL is updated again and now you’ve highlighted a range of lines. +试试这个:在查看文件的时候,点击挨着代码的行号。 -Sharing that URL will link to this file and those lines. But hold on, that’s pointing to the current branch. What if the file changes? Perhaps a permalink to the file in its current state is what you’re after. +哇哦,你看到了么?行号位置更新出了 URL !如果你按下 Shift 键并点击其他的行号,SHAZAAM ,URL 再一次更新并且现在出现了行范围的高亮。 -I’m lazy so I’ve done all of the above in one screenshot: +分享这个 URL 将会链接到这个文件的那些行。但等一下,链接所指向的是当前分支。如果文件发生变更了怎么办?也许一个文件当前状态的永久链接就是你以后需要的。 + +我比较懒,所以我已经在一张截图中做完了上面所有的步骤: ![](https://cdn-images-1.medium.com/max/1600/1*5Qg2GqTkTKuXLARasZN57A.png) -Speaking of URLs… +说起 URLs… -### #7 Using the GitHub URL like the command line +### #7 像命令行一样使用 GitHub URL -Navigating around GitHub using the UI is all well and fine. But sometimes the fastest way to get where you want to be is just to type it in the URL. For example, if I want to jump to a branch that I’m working on and see the diff with master, I can type `/compare/branch-name` after my repo name. +使用 UI 来浏览 GitHub 有着很好的体验。但有些时候最快到达你想去的地方的方法就是在地址栏输入。举个例子,如果我想要跳转到一个我正在工作的分支然后查看与 master 分支的 diff,我就可以在我的仓库名称的后边输入 `/compare/branch-name` 。 -That will land me on the diff page for that branch: +这样就会登录到指定分支的 diff 页面。 ![](https://cdn-images-1.medium.com/max/2000/1*DqexM1y398gSaozLNllroA.png) -That’s a diff with master though, if I was working off an integration branch, I’d type `/compare/integration-branch...my-branch` +然而这就是与 master 分支的 diff ,如果我正在 integration 分支工作,我可以输入 `/compare/integration-branch...my-branch`。 ![](https://cdn-images-1.medium.com/max/2000/1*roOXDuo_-9QKI5NLKmveGQ.png) -For you keyboard short-cutters out there, `ctrl`+`L` or `cmd`+`L` will jump the cursor up into the URL (in Chrome at least). This — coupled with the fact that your browser is going to do auto-complete — can make it a handy way to jump around between branches. +对于键盘上的快捷键,`ctrl`+`L` 或 `cmd`+`L` 将会向上跳转光标进入 URL 那里(至少在 Chrome 中是这样)。这一点 —— 加上你的浏览器会自动补全的事实 —— 能够成为一种在分支间跳转的便捷方式。 -Pro-tip: use the arrow keys to move through Chrome’s auto-complete suggestions and hit `shift`+`delete` to remove an item from history (e.g. once a branch is merged). +小贴士:使用方向键在 Chrome 的自动完成建议中移动同时按 `shift`+`delete` 来删除历史条目(e.g. 一旦分支被合并)。 -(I really wonder if those shortcuts would be easier to read if I did them like `shift + delete`. But technically the ‘+’ isn’t part of it, so I don’t feel comfortable with that. This is what keeps  _me_  up at night, Rhonda.) +(我真的好奇如果我把快捷键写成 `shift + delete` 这样的话,是不是读起来会更加容易。但严格来说 ‘+’ 并不是快捷键的一部分,所以我并不觉得这很舒服。这一点让 _我_ 整晚难以入睡,Rhonda。) -### #8 Create lists, in issues +### #8 在 issue 中创建列表 -Do you want to see a list of check boxes in your issue? +你想要在你的 issue 中看到一个复选框列表吗? ![](https://cdn-images-1.medium.com/max/1600/1*QIe-XOKOXTB3hXaLesr0zw.png) -And would you like that to show up as a nifty “2 of 5” bar when looking at the issue in a list? +想要在查看列表中的 issue 时候显示为一个漂亮的 “2 of 5” bar(译者注:条形码)吗? ![](https://cdn-images-1.medium.com/max/1600/1*06WdEpxuasda2-lavjjvNw.png) -That’s great! You can create interactive check boxes with this syntax: +那很好!你可以使用这些的语法创建交互式的复选框: ``` - [ ] Screen width (integer) @@ -128,208 +128,210 @@ That’s great! You can create interactive check boxes with this syntax: - [ ] Custom elements ``` -That’s a space and a dash and a space and a left bracket and a space (or an x) and a close bracket and a space and then some words. +表示方法是空格,破折号,再空格,左括号,填入空格(或者一个 x ),然后封闭括号 ,接着空格,最后是一些话。 -Then you can actually check/uncheck those boxes! For some reason this seems like technical wizardry to me. You can  _check_  the boxes! And it updates the underlying text! +然后其实你可以选中或取消选中这些框!出于一些原因这些对我来说看上去就像是技术的魔法。你可以 _选中_ 这些框! 同时底层的文本会进行更新。 -What will they think of next. +他们接下来会想什么? -Oh and if you have this issue on a project board, it will show the progress there too: +噢,如果你在一个 project board 上有这些 issue 的话,它也会在这里显示进度: ![](https://cdn-images-1.medium.com/max/1600/1*x_MzgCJXFp-ygsqFQB5qHA.png) -If you don’t know what I’m talking about when I say “on a project board” then you’re in for a treat further down the page. +如果在我提到“在一个 project board 上”时你不知道我在说些什么,那么你会在下面的页面进一步了解。 -Like, 2cm further down the page. +比如,在页面下 2 厘米的地方。 -### #9 Project boards in GitHub +### #9 GitHub 上的 Project boards -I’ve always used Jira for big projects. And for solo projects I’ve always used Trello. I quite like both of them. +我常常在大项目中使用 Jira 。而对于个人项目我总是会使用 Trello 。我很喜欢他们两个。 -When I learned a few weeks back that GitHub has its own offering, right there on the Projects tab of my repo, I thought I’d replicate a set of tasks that I already had on the boil in Trello. +当我学会的几周后 GitHub 有它自己的产品,就在我的仓库上的 Project 标签,我想过我会照搬一套我已经在 Trello 上进行的任务。 ![](https://cdn-images-1.medium.com/max/2000/1*NF7ZnHndZQ2SFUc5PK-Cqw.png) -None of them are funny +没有一个是有趣的 -And here’s the same in a GitHub project: +这里是在 GitHub project 上相同的内容: ![](https://cdn-images-1.medium.com/max/2000/1*CHsofapb4JtEDmveOvTYVQ.png) -Your eyes adjust to the lack of contrast eventually -For the sake of speed I added all of the above as ‘notes’ — which means they’re not actual GitHub issues. +你的眼睛会因为缺乏对比而适应。 -But the power of managing your tasks in GitHub is that it’s integrated with the rest of the repository — so you’ll probably want to add existing issues from the repo to the board. +出于速度的缘故,我把上面所有的都添加为 “notes” —— 意思是他们不是真正的 GitHub issue 。 -You can click Add Cards up in the top right and find the things you want to add. Here the special [search syntax][6] comes in handy, for example, type `is:pr is:open` and now you can drag any open PRs onto the board, or `label:bug` if you want to smash some bugs. +但在 GitHub 上,管理任务的权限被集成在版本库的其他地方 —— 所以你可能想要从仓库添加存在的 issue 到 board 上。 + +你可以点击右上角的 Add Cards 然后找你想要添加的东西。这里特殊的[搜索语法][6]就派上用场了,举个例子,输入 `is:pr is:open` 然后现在你可以拖动任何开启的 PRs 到 board 上,或者要是你想清理一些 bug 的话就输入 `label:bug` ![](https://cdn-images-1.medium.com/max/2000/1*rTVCR92HhIPhrVnOnXRZkQ.png) -Or you can convert existing notes to issues. +或者你可以将现有的 notes 转换为 issues 。 ![](https://cdn-images-1.medium.com/max/1600/1*pTm7dygsyLxsOUDkM7CTcg.png) -Or lastly, from an existing issue’s screen, add it to a project in the right pane. +或者最后,从一个现有的 issue 屏幕,把它添加到在右边面板的一个 project 。 ![](https://cdn-images-1.medium.com/max/1600/1*Czs0cSc91tXv411uneEM9A.png) -It will go into a triage list on that project board so you can decide which column to put it in. -There’s a huge (huuuuge) benefit in having your ‘task’ definition in the same repo as the code that implements that task. It means that years from now you can do a git blame on a line of code and find your way back to the original rationale behind the task that resulted in that code, without needing to go and track it down in Jira/Trello/elsewhere. +它们将会进入一个 project board 的分类列表,这样你就能减少候选的列表的数量。 -#### The downsides +作为实现那些 task 的代码,在同一仓库下你所拥有的 ‘task’ 定义有一个巨大(超大)的好处。这意味着今后的几年你能够用一行代码做一个 git blame 并且找出方法回到最初在这个 task 后面写下那些代码的根据,不需要在 Jira、Trello 或其他地方寻找蛛丝马迹。 -I’ve been trialling doing all tasks in GitHub instead of Jira for the last three weeks (on a smaller project that is kinda-sorta Kanban style) and I’m liking it so far. +#### 缺点 -But I can’t imagine using it on scrum project where I want to do proper estimating and calculate velocity and all that good stuff. +在过去的三周我已经对所有的 tasks 使用 GitHub 取代 Jira 进行了测试(在有点看板风格的较小规模的项目上) ,到目前为止我都很喜欢。 -The good news is, there are so few ‘features’ of GitHub Projects that it won’t take you long to assess if it’s something you could switch to. So give it a crack, see what you think. +但是我无法想象在 scrum (译者注:迭代式增量软件开发过程)项目上使用,我想要在那里完成正确估算、速度的测算以及所有的好东西。 -FWIW, I have  _heard_  of [ZenHub][7] and opened it up 10 minutes ago for the first time ever. It effectively extends GitHub so you can estimate your issues and create epics and dependencies. There’s velocity and burndown charts too; it looks like it  _might just be_  the greatest thing on earth. +好消息是,GitHub Projects 只有很少一些“功能”,并不会让你花很长时间去评估它是否值得让你去切换。因此留下一个悬念,看看你是怎么想的。 -Further reading: [GitHub help on Projects][8]. +总的来说,我有 _得知_ [ZenHub][7] 并且打开过 10 分钟,这也是有史以来的第一次。它是对 GitHub 高效的延伸,可以让你估计你的 issue 并创建 epics 和 dependencies。它也有速度和燃尽图功能;这看起来 _可能是_ 这地球上最伟大的事情。 + +延伸阅读: [GitHub help on Projects][8]。 ### #10 GitHub wiki -For an unstructured collection of pages — just like Wikipedia — the GitHub Wiki offering (which I will henceforth refer to as Gwiki) is great. +对于非结构化集合类的页面 —— 就像 Wikipedia —— GitHub Wiki 提供的(下文我会称之为 Gwiki )就很优秀。 -For a structured collection of pages — for example, your documentation — not so much. There is no way to say “this page is a child of that page”, or have nice things like ‘Next section’ and ‘Previous section’ buttons. And Hansel and Gretel would be screwed, because there’s no breadcrumbs. +对于结构化集合类的页面 —— 举个例子,你的文档 —— 并没那么多。这里没办法说“这个页面是那个页面的子页”,或者有像‘下一节’和‘上一节’这样的按钮。Hansel 和 Gretel 将会完蛋,因为这里没有面包屑(译者注:引自童话故事《糖果屋》)。 -(Side note, have you  _read_  that story? It’s brutal. The two jerk kids murder the poor hungry old woman by burning her to death in her  _own oven_ . No doubt leaving her to clean up the mess. I think this is why youths these days are so darn sensitive — bedtime stories nowadays don’t contain enough violence.) +(边注,你有 _读过_ 那个故事吗? 这是个残酷的故事。两个混蛋小子将饥肠辘辘的老巫婆烧死在 _她自己的火炉_ 里。无疑留下她来收拾残局。我想这就是为什么如今的年轻人是如此的敏感 —— 今天的睡前故事没有太多的暴力内容。) -Moving on — to take Gwiki for a spin, I entered a few pages from the NodeJS docs as wiki pages, then created a custom sidebar so that I could emulate having some actual structure. The sidebar is there at all times, although it doesn’t highlight the page you are currently on. +继续 —— 把 Gwiki 拿出来接着讲,我输入一些 NodeJS 文档中的内容作为 wiki 页面,然后创建一个侧边栏让我能够模拟出一些真实结构。这个侧边栏会一直存在,尽管它无法高亮显示你当前所在的页面。 -Links have to be manually maintained, but over all, I think it would work just fine. [Take a look][9] if you feel the need. +链接不得不手动维护,但总的来说,我认为这已经很好了。如果你觉得有需要的话可以[看一下][9]。  ![](https://cdn-images-1.medium.com/max/1600/1*BSKQpkLmVQpUML0Je9WsLQ.png) -It’s not going to compete with something like GitBook (that’s what the [Redux docs][10] use) or a bespoke website. But it’s a solid 80% and it’s all right there in your repo. +它将不会与像 GitBook(它使用了[Redux 文档][10])或一个定制的网站这样的东西去竞争。但它仍然会占据 80% 的页面而且就在你的仓库里。 -I’m a fan. +我是一个粉丝。 -My suggestion: if you’ve outgrown a single `README.md` file and want a few different pages for user guides or more detailed documentation, then your next stop should be a Gwiki. +我的建议:如果你已经拥有不止一个 `README.md` 文件并且想要一些不同的页面作为用户指南或是更详细的文档,那么下一步你就需要停止使用 Gwiki 了。 -If you start to feel the lack of structure/navigation is holding you back, move on to something else. +如果你开始觉得缺少的结构或导航非常有必要的话,去切换到其他的产品吧。 -### #11 GitHub Pages (with Jekyll) +### #11 GitHub Pages (带有 Jekyll) -You may already know that you can use GitHub Pages to host a static site. And if you didn’t now you do. However this section is specifically about using  _Jekyll_ to build out a site. +你可能已经知道了可以使用 GitHub Pages 来托管静态站点。如果你不知道的话现在就可以去试试。不过这一节确切的说是关于使用 _Jekyll_ 来构建一个站点。 -At its very simplest, GitHub Pages + Jekyll will render your `README.md` in a pretty theme. For example, take a look at my readme page from [about-github][11]: +最简单的就是, GitHub Pages + Jekyll 会将你的 `README.md` 呈现在一个漂亮的主题中。举个例子,从 [关于 github][11] 看看我的 readme 页面: ![](https://cdn-images-1.medium.com/max/2000/1*nU-vZfChZ0mZw9zO-6iJow.png) -If I click the ‘settings’ tab for my site in GitHub, turn on GitHub Pages, and pick a Jekyll theme… +如果我为我的 GitHub 站点点击 ‘settings’ 标签,开启 GitHub Pages,然后挑选一个 Jekyll 主题… ![](https://cdn-images-1.medium.com/max/1600/1*tT9AS7tNfEjbAcT3mkzgdw.png) -I will get a [Jekyll-themed page][12]: +我会得到一个[ Jekyll 主题页面][12]: ![](https://cdn-images-1.medium.com/max/2000/1*pIE2FMyWih7nFAdP-yGXtQ.png) -From this point on I can build out a whole static site based mostly around markdown files that are easily editable, essentially turning GitHub into a CMS. +根据这一点我可以构建一个主要基于易于编辑的 markdown 文件的静态站点,本质上是把 GitHub 变成一个 CMS(译者注:内容管理系统)。 -I haven’t actually used it, but this is how the React and Bootstrap sites are made, so it can’t be terrible. +我还没有真正的使用过它,但这就是 React 和 Bootstrap 站点构建的过程,所以并不可怕。 -Note, it requires Ruby to run locally (Windows users will exchange knowing glances and walk in the other direction. macOS users will be like “What’s the problem, where are you going? Ruby is a universal platform! GEMS!”) +注意,在本地运行需要 Ruby ( Windows 用户就需要交换一下眼色并且转向其他的方向。macOS 用户会像这样 “出什么问题了,你要去哪里?Ruby 是一个通用平台!GEMS!”)。 -(It’s also worth adding here that “Violent or threatening content or activity” is not allowed on GitHub Pages, so you can’t go hosting your Hansel and Gretel reboot.) +(这里也有必要加上“暴力或威胁的内容或活动” 在 GitHub Pages 上是不被允许的,因此你不能去部署重启你的 Hansel 和 Gretel 。) -#### My opinion +#### 我的意见 -The more I looked into GitHub Pages + Jekyll (for this post), the more it seemed like there was something a bit strange about the whole thing. +我观察的 GitHub Pages + Jekyll 越多(为了这篇文章),整件事情好像越是看起来有一点奇怪。 -The idea of ‘taking all the complexity out of having your own web site’ is great. But you still need a build setup to work on it locally. And there’s an awful lot of CLI commands for something so ‘simple’. +‘让所有的复杂性远离你所拥有的属于自己的网站’这样的想法是很棒的。但是你仍然需要在本地生成配置。而且可怕的是需要为这样“简单”的东西使用很多 CLI(译者注:命令行界面)命令。 -I just skimmed over the seven pages in the [Getting Started section][13], and I feel like  _I’m_  the only simple thing around here. And I haven’t even learnt the simple “Front Matter” syntax or the ins and outs of the simple “Liquid templating engine” yet. +我只是略读了[入门部分][13]的七页,给我的感觉像是 _我是_ 这里仅有的简单的事情。此前我甚至从来没有学习过所谓简单的“Front Matter”的语法或者所谓简单的“Liquid 模板引擎”的来龙去脉。 -I’d rather just write a website. +我宁愿只写一个网站。 -To be honest I’m a bit surprised Facebook use this for the React docs when they could probably build their help docs with React and [pre-render to static HTML files][14] in under a day. +老实说我有点惊讶 Facebook 使用它来写 React 文档,因为他们能够用 React 来构件他们的帮助文档并且在一天之内 [pre-render 预渲染到静态的 HTML 文件][14]。 -All they would need is some way to consume their existing markdown files as though they were coming from a CMS. +他们所需要的就跟使用 CMS 中已有的 Markdown 文件一样。 -I wonder if… +我想是这样… -### #12 Using GitHub as a CMS +### #12 使用 GitHub 作为 CMS -Let’s say you have a website with some text in it, but you don’t want to store that text in the actual HTML markup. +比如说你有一个带有一些文本的网站,但是你并不想在 HTML 的标记中储存那些文本。 -Instead, you want to store chunks of text somewhere so they can easily be edited by non-developers. Perhaps with some form of version control. Maybe even a review process. +取而代之,你想要存放文本块到一个很容易被非开发者编辑的地方。也许使用一些版本控制的形式。甚至可能是一个审查过程。 -Here’s my suggestion: use markdown files stored in your repository to hold the text. Then have a component in your front end that fetches those chunks of text and renders them on the page. +这里是我的建议:在你的版本库中使用 markdown 文件存储文本。然后在你的前端使用插件来获取这些文本块并在页面呈现。 -I’m a React guy, so here’s an example of a `` component that, given the path to some markdown, will fetch, parse and render it as HTML. +我是 React 的支持者,因此这里有一个 `` 插件的示例,给出一些 markdown 的路径,它们将被获取,解析,并以 HTML 的形式呈现。 -(I’m using the [marked][1] npm package to parse the markdown into HTML.) +(我正在使用的是 [marked][1] npm 包来将 markdown 解析为 HTML。) -That’s pointing to my example repo that has some markdown files in `[/text-snippets][2]`. +这里是指向我的示例仓库 [/text-snippets][2],里边有一些 markdown 文件 。 -(You could also use the GiHub API to [get the contents][15] — but I’m not sure why you would.) +(你也可以前往[获取内容][15]页面获取 GiHub API 来使用 —— 但我不确定你是否可以。) -You would use such a component like so: +你可以使用像这样的插件: -So now GitHub is your CMS, sort of, for whatever chunks of text you want it to house. +所以现在 GitHub 就是你的 CMS,可以说,不管有多少文本块都可以放进去。 -The above example only fetches the markdown after the component has mounted in the browser. If you want a static site then you’ll want to server-render this. +上边的示例只是在浏览器上安装好插件后获取 markdown 。如果你想要一个静态站点那么你需要服务器端渲染(server-render)。 -Good news! There’s nothing stopping you from fetching all the markdown files on the server (coupled with whatever caching strategy works for you). If you go down that road you might want to look at the GitHub API to get a list of all the markdown files in a directory. +好消息!没什么能阻止你从服务器中获取所有的 markdown 文件 (配上各种为你服务的缓存策略)。如果你沿着这条路继续走下去的话,你可能会想要去看看使用 GitHub API 去获取目录中的所有 markdown 文件的列表。 -### Bonus round — GitHub tools! +### Bonus round —— GitHub 工具! -I’ve used the [Octotree Chrome extension][16] for a while now and I recommend it. Not wholeheartedly, but I recommend it nonetheless. +我曾经使用过一段时间的 [Chrome 的扩展 Octotree ][16] 而且现在我推荐它。虽然并非真心诚意,但不管怎样我还是推荐它。 -It gives you a panel over on the left with a tree view of whatever repo you’re looking at. +它会在左侧提供一个带有树视图的面板以显示当前你所查看的仓库。 ![](https://cdn-images-1.medium.com/max/2000/1*-MgFq3TEjdys1coiF5-dCw.png) -From [this video][17] I learned about [octobox][18], which so far seems pretty good. It’s an inbox for your GitHub issues. That’s all I have to say about that. +从[这个视频][17]中我学会了 [octobox][18] ,到目前为止看起来还不错。它是一个 GitHub issues 的收件箱。这就是我要说的全部。 -Speaking of colors, I’ve taken all my screenshots above in the light theme so as not to startle you. But really, everything else I look at is dark themed, why must I endure a pallid GitHub? +说到颜色,在上面所有的截图中我都使用了亮色主题,所以不要吓到你。不过说真的,我看到的其他东西都是在黑色的主题上,为什么我非要忍受 GitHub 这个苍白的主题呐? ![](https://cdn-images-1.medium.com/max/2000/1*SUdLeoaq8AtVQyE-dCw-Tg.png) -That’s a combo of the [Stylish][19] Chrome extension (which can apply themes to any website) and the [GitHub Dark][20] style. And to complete the look, the dark theme of Chrome DevTools (which is built in, turn it on in settings) and the [Atom One Dark Theme][21] for Chrome. +这是由 Chrome 扩展 [Stylish][19](它可以在任何网站使用主题)和 [GitHub Dark][20] 风格的一个组合。同时为了完成这样的外观也需要,黑色主题的 Chrome 开发者工具(这是内建的,在设置中打开) 以及 [Atom One Dark for Chrome 主题][21]。 ### Bitbucket -This doesn’t strictly fit anywhere in this post, but it wouldn’t be right if I didn’t give a shout-out to Bitbucket. +这些并不完全适合这篇文章的所有地方,但是如果我不称赞 Bitbucket 的话,那就不对了。 -Two years ago I was starting a project and spent half a day assessing which git host was best, and Bitbucket won by a considerable margin. Their code review flow was just so far ahead (this was long before GitHub even had the concept of assigning a reviewer). +两年前我开始了一个项目并花了大半天时间评估哪一个 git 托管服务更适合,最终 Bitbucket 赢得了相当不错的成绩。他们的代码审查流程遥遥领先(这甚至比 GitHub 拥有的指派审阅者的概念要早很长时间)。 -GitHub has since caught up in the review game, which is great. But sadly I haven’t had the chance to use Bitbucket in the last year — perhaps they’ve bounded ahead in some other way. So, I would urge anyone in the position of choosing a git host to check out Bitbucket too. +GitHub 在后来赶上了比赛,这是非常成功的。但不幸的是在过去的一年里我没有机会使用 Bitbucket —— 也许他们依然在某些方面领先。所以,我会力劝每一个选择 git 托管服务的人也要考虑 Bitbucket 。 -### Outro +### 结尾 -So that’s it! I hope there were at least three things in here that you didn’t know already, and also I hope that you have a nice day. +就是这样!我希望这里至少有三件事是你此前并不知道的,我也希望你拥有愉快的一天。 -Edit: there’s more tips in the comments; feel free to leave your own favourite. And seriously, I really do hope you have a nice day. +编辑:在评论中有更多的建议;随便留下你自己喜欢的。真的,我真的希望你能拥有愉快的一天。 -------------------------------------------------------------------------------- via: https://hackernoon.com/12-cool-things-you-can-do-with-github-f3e0424cf2f0 作者:[David Gilbertson][a] -译者:[译者ID](https://github.com/译者ID) +译者:[softpaopao](https://github.com/softpaopao) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 076da2f5e1bb7081a4d7c47b5299d2b3aaa16d6a Mon Sep 17 00:00:00 2001 From: softpaopao Date: Mon, 9 Oct 2017 17:33:47 +0800 Subject: [PATCH 020/485] translated by softpaopao MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成,第9小节后边的内容不太好理解 --- .../tech/20170909 12 cool things you can do with GitHub.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20170909 12 cool things you can do with GitHub.md (100%) diff --git a/sources/tech/20170909 12 cool things you can do with GitHub.md b/translated/tech/20170909 12 cool things you can do with GitHub.md similarity index 100% rename from sources/tech/20170909 12 cool things you can do with GitHub.md rename to translated/tech/20170909 12 cool things you can do with GitHub.md From d5061b1c127fe5c2b8f8d5876717eb20a8b6fd7a Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Oct 2017 23:35:00 +0800 Subject: [PATCH 021/485] PRF:20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @toutoudnf 原文中前后名称不一致,以及命令中存在多余的空格。要是更仔细些就更好了。 --- ... The 8 possible scenarios using OpenSSH.md | 229 +++++++----------- 1 file changed, 82 insertions(+), 147 deletions(-) diff --git a/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md b/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md index 2df7a5f3c0..4f5a75e902 100644 --- a/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md +++ b/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md @@ -1,47 +1,26 @@ 通过 SSH 实现 TCP / IP 隧道(端口转发):使用 OpenSSH 可能的 8 种场景 ============================================================ -对于 [Secure Shell (SSH)][21] 这样的网络协议来说,其主要职责就是在终端模式下访问一个远程系统。因为 SSH 协议对传输数据进行了加密,所以通过它在远端系统执行命令是非常安全的。此外,我们还可以在这种加密后的连接上通过创建隧道(端口转发)的方式,来实现两个不同终端间的互联。凭借这种方式,只要我们能通过 SSH 创建连接,就可以绕开防火墙或者端口禁用的限制。 +对于 [Secure Shell (SSH)][21] 这样的网络协议来说,其主要职责就是在终端模式下访问一个远程系统。因为 SSH 协议对传输数据进行了加密,所以通过它在远端系统执行命令是安全的。此外,我们还可以在这种加密后的连接上通过创建隧道(端口转发)的方式,来实现两个不同终端间的互联。凭借这种方式,只要我们能通过 SSH 创建连接,就可以绕开防火墙或者端口禁用的限制。 -这个话题在网络领域被广泛应用和讨论: +这个话题在网络领域有大量的应用和讨论: * [Wikipedia: SSH Tunneling][12] - * [O’Reilly: Using SSH Tunneling][13] - * [Ssh.com: Tunneling Explained][14] - * [Ssh.com: Port Forwarding][15] - * [SecurityFocus: SSH Port Forwarding][16] - * [Red Hat Magazine: SSH Port Forwarding][17] 我们在接下来的内容中并不讨论端口转发的细节,而是准备介绍一个如何使用 [OpenSSH][22] 来完成 TCP 端口转发的速查表,其中包含了八种常见的场景。有些 SSH 客户端,比如 [PuTTY][23],也允许通过界面配置的方式来实现端口转发。而我们着重关注的是通过 OpenSSH 来实现的的方式。 -在下面的例子当中,我们假设环境中的网络划分为外部网络(network1)和内部网络(network2)两部分,并且这两个网络之间,只能在 external1 与 internal1 之间通过 SSH 连接的方式来互相访问。外部网络的节点之间和内部网络的节点之间是完全联通的。 +在下面的例子当中,我们假设环境中的网络划分为外部网络(network1)和内部网络(network2)两部分,并且这两个网络之间,只能在 externo1 与 interno1 之间通过 SSH 连接的方式来互相访问。外部网络的节点之间和内部网络的节点之间是完全联通的。 ![SSH tunnels: no tunnel](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_sin_tunel.png) -内容列表: +### 场景 1 -* [1 场景 1 :在 external1 节点访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = localhost / 主机 = localhost )][2] - -* [2 场景 2:在 external2 节点上访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost)][3] - -* [3 场景 3:在 internal1 上访问由 external1 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / 主机 = localhost)][4] - -* [4 场景 4 :internal2 使用 external1 上提供的 TCP 服务(远端端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost)][5] - -* [5 场景 5 :在 external1 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 localhost / 主机 = internal2 )][6] - -* [6 场景 6 :在 internal1 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / host = external2)][7] - -* [7 场景7 :在 external2 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = internal2)][8] - -* [8 场景 8 : 在 internal2 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = 0.0.0.0 / 主机 = external2)][9] - -#### 场景 1 :在 external1 节点访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = localhost / 主机 = localhost ) +> 在 externo1 节点访问由 interno1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = localhost / 主机 = localhost ) externo1 节点可以通过 OpenSSH 连接到 interno1 节点,之后我们想通过其访问运行在 5900 端口上的 VNC 服务。 @@ -50,13 +29,13 @@ externo1 节点可以通过 OpenSSH 连接到 interno1 节点,之后我们想 我们可以通过下面的命令来实现: ``` -External1 $ ssh -L 7900: localhost: 5900 user @ internal1 +externo1 $ ssh -L 7900:localhost:5900 user@interno1 ``` 现在,我们可以在 externo1 节点上确认下 7900 端口是否处于监听状态中: ``` -External1 $ netstat -ltn +externo1 $ netstat -ltn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State       ... @@ -64,40 +43,32 @@ Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN   ... ``` -我们只需要在 external1 节点上执行如下命令即可访问 internal 节点的 VNC 服务。: +我们只需要在 externo1 节点上执行如下命令即可访问 internal 节点的 VNC 服务: ``` -External1 $ vncviewer localhost :: 7900 +externo1 $ vncviewer localhost::7900 ``` -注意:在下面的文档中并未提及这种修改端口号的方式。在[About VNCViewer configuration of the output TCP port][18] 中可以看到。这也是 [the TightVNC vncviewer][19] 所介绍的的。 +注意:在 [vncviewer 的 man 手册](http://www.realvnc.com/products/free/4.1/man/vncviewer.html)中并未提及这种修改端口号的方式。在 [About VNCViewer configuration of the output TCP port][18] 中可以看到。这也是 [the TightVNC vncviewer][19] 所介绍的的。 -``` -man vncviewer -``` +### 场景 2 -#### 场景 2:在 external2 节点上访问由 internal1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) +> 在 externo2 节点上访问由 interno1 节点提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) -这次的场景跟方案 1 的场景的类似,但是我们这次想从 external2 节点来连接到 internal1 上的 VNC 服务: +这次的场景跟方案 1 的场景的类似,但是我们这次想从 externo2 节点来连接到 interno1 上的 VNC 服务: ![SSH Tunnels: Scenario 2](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_2.png) 正确的命令如下: ``` -External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 +externo1 $ ssh -L 0.0.0.0:7900:localhost:5900 user@interno1 ``` -看起来跟方案 1 中的命令类似,但是让我们看看 netstat 命令的输出上的区别: +看起来跟方案 1 中的命令类似,但是让我们看看 `netstat` 命令的输出上的区别。7900 端口被绑定到了本地(`127.0.0.1`),所以只有本地进程可以访问。这次我们将端口关联到了 `0.0.0.0`,所以系统允许任何 IP 地址的机器访问 7900 这个端口。 ``` -netstat -``` - -7900 端口被绑定到了本地(127.0.0.1),所以只有本地进程可以访问。这次我们将端口关联到了 0.0.0.0,所以系统允许任何 IP 地址的机器访问 7900 这个端口。 - -``` -External1 $ netstat -ltn +externo1 $ netstat -ltn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State       ... @@ -105,44 +76,32 @@ Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN ... ``` -所以现在在 external2 节点上,我们可移执行: +所以现在在 externo2 节点上,我们可以执行: ``` -External2 $ vncviewer external1 :: 7900 +externo2 $ vncviewer externo1::7900 ``` -来连接到 internal1 节点上的 VNC 服务。 +来连接到 interno1 节点上的 VNC 服务。 -除了将 IP 指定为 +除了将 IP 指定为 `0.0.0.0` 之外,我们还可以使用参数 `-g`(允许远程机器使用本地端口转发),完整命令如下: ``` -0.0.0.0 -``` - -之外,我们还可以使用如下参数: - -``` --g -``` - -(允许远程机器使用本地端口转发),完整命令如下: - -``` -External1 $ ssh -g -L 7900: localhost: 5900 user @ internal1 +externo1 $ ssh -g -L 7900:localhost:5900 user@interno1 ``` 这条命令与前面的命令能实现相同效果: ``` -External1 $ ssh -L 0.0.0.0:7900:localhost:5900 user @ internal1 +externo1 $ ssh -L 0.0.0.0:7900:localhost:5900 user@interno1 ``` -换句话说,如果我们想限制只有指定 IP 的机器才能访问转发端口,可以像下面这样定义: +换句话说,如果我们想限制只能连接到系统上的某个 IP,可以像下面这样定义: ``` -External1 $ ssh -L 192.168.24.80:7900:localhost:5900 user @ internal1 +externo1 $ ssh -L 192.168.24.80:7900:localhost:5900 user@interno1 -External1 $ netstat -ltn +externo1 $ netstat -ltn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State ... @@ -150,34 +109,26 @@ Tcp 0 0 192.168.24.80:7900 0.0.0.0:* LISTEN ... ``` -#### 场景 3:在 internal1 上访问由 external1 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / 主机 = localhost) +### 场景 3 + +> 在 interno1 上访问由 externo1 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / 主机 = localhost) 在场景 1 中 SSH 服务器与 TCP 服务(VNC)提供者在同一个节点上。现在我们想在 SSH 客户端所在的节点上,提供一个 TCP 服务(VNC)供 SSH 服务端来访问: ![SSH Tunnels: Scenario 3](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_3.png) -将方案 1 中的命令参数由: - -``` --L -``` - -替换为 - -``` --R -``` +将方案 1 中的命令参数由 `-L` 替换为 `-R`。 完整命令如下: ``` -External1 $ ssh -R 7900: localhost: 5900 user @ internal1 +externo1 $ ssh -R 7900:localhost:5900 user@interno1 ``` 然后我们就能看到 interno1 节点上对 7900 端口正在监听: ``` -Internal1 $ netstat -lnt +interno1 $ netstat -lnt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State ... @@ -185,61 +136,37 @@ Tcp 0 0 127.0.0.1:7900 0.0.0.0:* LISTEN ... ``` -现在在 internal1 节点上,我们可以使用如下命令来访问 external1 上的 VNC 服务。 +现在在 interno1 节点上,我们可以使用如下命令来访问 externo1 上的 VNC 服务: ``` -Internal1 $ vncviewer localhost :: 7900 +interno1 $ vncviewer localhost::7900 ``` -#### 场景 4 :internal2 使用 external1 上提供的 TCP 服务(远端端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) +### 场景 4 -与场景 3 类似,但是现在我们尝试指定允许访问转发端口的 IP(就像方案 2 中做的一样) +> interno2 使用 externo1 上提供的 TCP 服务(远端端口转发 / 绑定地址 = 0.0.0.0 / 主机 = localhost) -``` -0.0.0.0 -``` - -这样其他节点也可以访问 VNC 服务: +与场景 3 类似,但是现在我们尝试指定允许访问转发端口的 IP(就像场景 2 中做的一样)为 `0.0.0.0`,这样其他节点也可以访问 VNC 服务: ![SSH Tunnels: Scenario 4](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_4-1.png) 正确的命令是: ``` -External1 $ ssh -R 0.0.0.0:7900:localhost:5900 user @ internal1 +externo1 $ ssh -R 0.0.0.0:7900:localhost:5900 user@interno1 ``` -但是如果我们直接执行该命令的话可能不会生效,因为我们需要修改 SSH 服务端的一个参数值: - -``` -GatewayPorts -``` - -他的默认值是: - -``` -no -``` +但是这里有个重点需要了解,出于安全的原因,如果我们直接执行该命令的话可能不会生效,因为我们需要修改 SSH 服务端的一个参数值 `GatewayPorts`,它的默认值是:`no`。 > GatewayPorts > -> 该参数指定了是否允许远程主机访问转发端口。默认情况下,sshd(8) 只允许本机进程访问转发端口。这是为了阻止其他主机连接到该转发端口。GatewayPorts 参数可用于指定 sshd 允许哪些远程主机访问转发端口。当参数值设置为 “no” 的时候只有本机可以访问转发端口;“yes” 则表示允许符合远程主机 IP 地址通配符规则的远程主机访问该转发端口;“clientspecified” 则表示由客户端来选择哪些主机地址允许访问转发端口。默认值是 “no”。 +> 该参数指定了远程主机是否允许客户端访问转发端口。默认情况下,sshd(8) 只允许本机进程访问转发端口。这是为了阻止其他主机连接到该转发端口。GatewayPorts 参数可用于让 sshd 允许远程转发端口绑定到非回环地址上,从而可以让远程主机访问。当参数值设置为 “no” 的时候只有本机可以访问转发端口;“yes” 则表示允许远程转发端口绑定到通配地址上;或者设置为 “clientspecified” 则表示由客户端来选择哪些主机地址允许访问转发端口。默认值是 “no”。 -如果我们没有修改服务器配置的权限,我们将不能使用该方案来进行端口转发。这是因为如果没有其他的限制,用户可以开启一个端口(> 1024)来监听来自外部的请求并转发到: - -``` -localhost:7900 -``` +如果我们没有修改服务器配置的权限,我们将不能使用该方案来进行端口转发。这是因为如果没有其他的限制,用户可以开启一个端口(> 1024)来监听来自外部的请求并转发到 `localhost:7900`。 参照这个案例:[netcat][24] ( [Debian # 310431: sshd_config should warn about the GatewayPorts workaround.][25] ) -所以我们修改: - -``` -/etc/ssh/sshd_config -``` - -添加如下内容: +所以我们修改 `/etc/ssh/sshd_config`,添加如下内容: ``` GatewayPorts clientspecified @@ -251,10 +178,10 @@ GatewayPorts clientspecified sudo /etc/init.d/ssh reload ``` -我们确认现在 internal1 节点上存在 7900 端口的监听程序,监听来自不同 IP 的请求: +我们确认一下现在 interno1 节点上存在 7900 端口的监听程序,监听来自不同 IP 的请求: ``` -Internal1 $ netstat -ltn +interno1 $ netstat -ltn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State ... @@ -262,74 +189,82 @@ Tcp 0 0 0.0.0.0:7900 0.0.0.0:* LISTEN ... ``` -然后我们就可以在 internal2 节点上使用 VNC 服务了: +然后我们就可以在 interno2 节点上使用 VNC 服务了: ``` -Internal2 $ internal vncviewer1 :: 7900 +interno2 $ internal vncviewer1::7900 ``` -#### 场景 5 :在 external1 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 localhost / 主机 = internal2 ) +### 场景 5 + +> 在 externo1 上使用由 interno2 提供的 TCP 服务(本地端口转发 / 绑定地址 localhost / 主机 = interno2 ) ![SSH Tunnels: Scenario 5](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_5.png) 在这种场景下我们使用如下命令: ``` -External1 $ ssh -L 7900: internal2: 5900 user @ internal1 +externo1 $ ssh -L 7900:interno2:5900 user@interno1 ``` -然后我们就能在 external1 节点上,通过执行如下命令来使用 VNC 服务了: +然后我们就能在 externo1 节点上,通过执行如下命令来使用 VNC 服务了: ``` -External1 $ vncviewer localhost :: 7900 +externo1 $ vncviewer localhost::7900 ``` -#### 场景 6 :在 internal1 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / host = external2) +### 场景 6 + +> 在 interno1 上使用由 externo2 提供的 TCP 服务(远程端口转发 / 绑定地址 = localhost / host = externo2) ![SSH Tunnels: Scenario 6](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_6.png) 在这种场景下,我们使用如下命令: ``` -External1 $ ssh -R 7900: external2: 5900 user @ internal1 +externo1 $ ssh -R 7900:externo2:5900 user@interno1 ``` -然后我们可以在 internal1 上通过执行如下命令来访问 VNC 服务: +然后我们可以在 interno1 上通过执行如下命令来访问 VNC 服务: ``` -Internal1 $ vncviewer localhost :: 7900 +interno1 $ vncviewer localhost::7900 ``` -#### 场景7 :在 external2 上使用由 internal2 提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = internal2) +### 场景7 + +> 在 externo2 上使用由 interno2 提供的 TCP 服务(本地端口转发 / 绑定地址 = 0.0.0.0 / 主机 = interno2) ![SSH Tunnels: Scenario 7](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_7.png) 本场景下,我们使用如下命令: ``` -External1 $ ssh -L 0.0.0.0:7900:internal2:5900 user @ internal1 +externo1 $ ssh -L 0.0.0.0:7900:interno2:5900 user@interno1 ``` 或者: ``` -External1 $ ssh -g -L 7900: internal2: 5900 user @ internal1 +externo1 $ ssh -g -L 7900:interno2:5900 user@interno1 ``` -然后我们就可以在 external2 上执行如下命令来访问 vnc 服务: +然后我们就可以在 externo2 上执行如下命令来访问 vnc 服务: ``` -External2 $ vncviewer external1 :: 7900 +externo2 $ vncviewer externo1::7900 ``` -#### 场景 8 : 在 internal2 上使用由 external2 提供的 TCP 服务(远程端口转发 / 绑定地址 = 0.0.0.0 / 主机 = external2) +### 场景 8 + +> 在 interno2 上使用由 externo2 提供的 TCP 服务(远程端口转发 / 绑定地址 = 0.0.0.0 / 主机 = externo2) ![SSH Tunnels: Scenario 8](https://wesharethis.com/wp-content/uploads/2017/07/ssh_tunnel_8.png) 本场景下我们使用如下命令: ``` -External1 $ ssh -R 0.0.0.0:7900:external2:5900 user @ internal1 +externo1 $ ssh -R 0.0.0.0:7900:externo2:5900 user@interno1 ``` SSH 服务器需要配置为: @@ -340,13 +275,13 @@ GatewayPorts clientspecified 就像我们在场景 4 中讲过的那样。 -然后我们可以在 internal2 节点上执行如下命令来访问 VNC 服务: +然后我们可以在 interno2 节点上执行如下命令来访问 VNC 服务: ``` -Internal2 $ internal vncviewer1 :: 7900 +interno2 $ internal vncviewer1::7900 ``` -如果我们需要一次性的创建多个隧道,使用配置文件的方式替代一个可能很长的命令是一个更好的选择。假设我们只能通过 SSH 的方式访问某个特定网络,同时又需要创建多个隧道来访问该网络内不同服务器上的服务,比如 VNC 或者 [远程桌面][26]。此时只需要创建一个如下的配置文件即可(在 SOCKS 服务器 上)。 +如果我们需要一次性的创建多个隧道,使用配置文件的方式替代一个可能很长的命令是一个更好的选择。假设我们只能通过 SSH 的方式访问某个特定网络,同时又需要创建多个隧道来访问该网络内不同服务器上的服务,比如 VNC 或者 [远程桌面][26]。此时只需要创建一个如下的配置文件 `$HOME/redirects` 即可(在 SOCKS 服务器 上)。 ``` # SOCKS server @@ -370,29 +305,29 @@ LocalForward 5903 172.16.23.45:5901 然后我们只需要执行如下命令: ``` -External1 $ ssh -F $ HOME / redirects user @ internal1 +externo1 $ ssh -F $HOME/redirects user@interno1 ``` -------------------------------------------------------------------------------- via: https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/ -作者:[ Ahmad][a] +作者:[Ahmad][a] 译者:[toutoudnf](https://github.com/toutoudnf) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://wesharethis.com/author/ahmad/ [1]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/# -[2]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_1_Use_onexternal1a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_localhost_host_localhost -[3]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_2_Use_onexternal2a_TCP_service_offered_byinternal1Local_port_forwarding_bind_address_0000_host_localhost -[4]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_3_Use_ininternal1a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_localhost_host_localhost -[5]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_4_Use_ininternal2a_TCP_service_offered_byexternal1Remote_port_forwarding_bind_address_0000_host_localhost -[6]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_5_Use_inexternal1a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_localhost_host_internal2 -[7]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_6_Use_ininternal1a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_localhost_host_external2 -[8]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_7_Use_inexternal2a_TCP_service_offered_byinternal2Local_port_forwarding_bind_address_0000_host_internal2 -[9]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_8_Use_ininternal2a_TCP_service_offered_byexternal2Remote_port_forwarding_bind_address_0000_host_external2 +[2]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_1_Use_onexterno1a_TCP_service_offered_byinterno1Local_port_forwarding_bind_address_localhost_host_localhost +[3]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_2_Use_onexterno2a_TCP_service_offered_byinterno1Local_port_forwarding_bind_address_0000_host_localhost +[4]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_3_Use_ininterno1a_TCP_service_offered_byexterno1Remote_port_forwarding_bind_address_localhost_host_localhost +[5]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_4_Use_ininterno2a_TCP_service_offered_byexterno1Remote_port_forwarding_bind_address_0000_host_localhost +[6]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_5_Use_inexterno1a_TCP_service_offered_byinterno2Local_port_forwarding_bind_address_localhost_host_interno2 +[7]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_6_Use_ininterno1a_TCP_service_offered_byexterno2Remote_port_forwarding_bind_address_localhost_host_externo2 +[8]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_7_Use_inexterno2a_TCP_service_offered_byinterno2Local_port_forwarding_bind_address_0000_host_interno2 +[9]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#Scenario_8_Use_ininterno2a_TCP_service_offered_byexterno2Remote_port_forwarding_bind_address_0000_host_externo2 [10]:https://wesharethis.com/author/ahmad/ [11]:https://wesharethis.com/2017/07/creating-tcp-ip-port-forwarding-tunnels-ssh-8-possible-scenarios-using-openssh/#comments [12]:http://en.wikipedia.org/wiki/Tunneling_protocol#SSH_tunneling From 31aac1ef1f668574d5121eea3e9d9af636ca62b5 Mon Sep 17 00:00:00 2001 From: wxy Date: Mon, 9 Oct 2017 23:35:30 +0800 Subject: [PATCH 022/485] PUB:20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md @toutoudnf https://linux.cn/article-8945-1.html --- ...ing tunnels with SSH The 8 possible scenarios using OpenSSH.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md (100%) diff --git a/translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md b/published/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md similarity index 100% rename from translated/tech/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md rename to published/20170714 Creating TCP IP port forwarding tunnels with SSH The 8 possible scenarios using OpenSSH.md From bcfe6740e58a815994423a92a3b1a7b6713a8acc Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 10 Oct 2017 08:36:23 +0800 Subject: [PATCH 023/485] translated --- ...7 What all you need to know about HTML5.md | 274 ------------------ 1 file changed, 274 deletions(-) delete mode 100644 sources/tech/20170617 What all you need to know about HTML5.md diff --git a/sources/tech/20170617 What all you need to know about HTML5.md b/sources/tech/20170617 What all you need to know about HTML5.md deleted file mode 100644 index fb366a77de..0000000000 --- a/sources/tech/20170617 What all you need to know about HTML5.md +++ /dev/null @@ -1,274 +0,0 @@ -translating---geekpi - -What all you need to know about HTML5 -============================================================ - - - _![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/handwritten-html5-peter-booth-e-plus-getty-images-56a6faec5f9b58b7d0e5d1cf.jpg?resize=700%2C467)_ - - _HTML5, the fifth and current version of the HTML standard, is a markup language used to structure and present content on the World Wide Web. This article will help readers get acquainted with it._ - -HTML5 has evolved through the cooperation between the W3C and the Web Hypertext Application Technology Working Group. It is a higher version of HTML, and its many new elements make your pages more semantic and dynamic. It was developed to provide a greater Web experience for everyone. HTML5 offers great features that make the Web more dynamic and interactive. - -The new features of HTML5 are: - -* New sets of tags such as
and
- -* element for 2D drawing - -* Local storage - -* New form controls like calendar, date and time - -* New media functionality - -* Geo-location - -HTML5 is not an official standard as yet; hence, not all browsers support it or some of its features. One of the most important reasons behind developing HTML5 was to prevent users from having to download and install multiple plugins like Silverlight and Flash. - -**New tags and elements** - -**Semantic elements:** Figure 1 displays a few useful semantic elements. -**Form elements:** The form elements present in HTML5 are shown in Figure 2. -**Graphic elements:** The graphic elements in HTML5 can be seen in Figure 3. -**Media elements:** The new media elements in HTML5 are listed in Figure 4. - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-1-7.jpg?resize=350%2C277)][3] - -Figure 1: Semantic elements - - [![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-2-5.jpg?resize=350%2C108)][4] - -Figure 2: Form elements - -**Advanced features of HTML5** - -**Geo-location** - -It is an HTML5 API that is used to get the geographical location of a website’s user, who has to first permit the site to fetch his or her location. This usually happens via a button and/or browser popup. All the latest versions of Chrome, Firefox, IE, Safari and Opera can use the geo-location feature of HTML5. - -Some uses of geo-location are: - -* Public transportation websites - -* Taxi and other transportation websites - -* To calculate shipping costs on an e-commerce site - -* Travel agency websites - -* Real estate websites - -* Movie theatre websites can find movies playing nearby - -* Online gaming - -* For sites to feature local headlines and weather on their front page - -* Job postings can automatically include commute times - -**How it works:** Geo-location works by scanning common sources of location information, which include the following: - -* Global Positioning System (GPS), which is the most accurate - -* Network signals—IP address, RFID, Wi-Fi and Bluetooth MAC addresses - -* GSM/CDMA cell IDs - -* User inputs - -The API offers a very handy function to detect geo-location support in browsers: - -| `if` `(navigator.geolocation) {``//` `do` `stuff``}` | - -The  _getCurrentPosition_  API is the main method for using geo-location. It retrieves the current geographic location of the user’s device. The location is described as a set of geographic coordinates along with the heading and speed. The location information is returned as a position object. - -The syntax is: - -`getCurrentPosition(showLocation, ErrorHandler, options);` - -* _showLocation:_  This defines the callback method that retrieves location information. - -* _ErrorHandler(Optional):_  This defines the callback method that is invoked when an error occurs in processing the asynchronous call. - -* _options (Optional):_  This defines a set of options for retrieving the location information. - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-3-2.jpg?resize=350%2C72)][5] - -Figure 3: Graphic elements - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-4-2.jpg?resize=350%2C144)][6] - -Figure 4: Media elements - -Figure 5 incorporates the set of properties returned by a position object. - -We can present location information to the user in two ways—geodetic and civil: - -1\. The geodetic way of describing a position refers directly to the latitude and longitude. -2\. The civic representation of location data is readable and easily understood by humans. - -As shown in Table 1, each attribute/parameter has both a geodetic representation and a civic representation. - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/table-1.jpg?resize=350%2C132)][7] - -**Web storage** - -In HTML, to store user data on a local machine, we were using JavaScript cookies. To avoid that, HTML5 has introduced Web storage, with which websites themselves store user data on a local machine. - -The advantages of Web storage, as compared to cookies, are: - -* More secure - -* Faster - -* Stores a larger amount of data - -* The stored data is not sent with every server request. It is only included when asked for. This is a big advantage of HTML5 Web storage over cookies. - -There are two types of Web storage objects: - -1) Local – this stores data with no expiration date. -2) Session – this stores data for one session only. - -**How it works:** The  _localStorage_  and  _sessionStorage_  objects create a  _key = value pair._ - -An example is: _ key=“Name”,_   _value=“Palak”_ - -These are stored as strings but can be converted, if required, by using JavaScript functions like  _parseInt()_  and  _parseFloat()_ . - -Given below is the syntax for using Web storage objects: - - `Storing a Value:``• localStorage.setItem(“key1”, “value1”);``• localStorage[“key1”] = “value1”;``Getting a Value:``• alert(localStorage.getItem(“key1”));``• alert(localStorage[“key1”]);``Remove a Value:``• removeItem(“key1”);``Remove All Values:``• localStorage.``clear``();` - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure5-1.jpg?resize=350%2C202)][8] - -Figure 5: Position object properties - -**Application Cache (AppCache)** - -Using HTML5 Apache, we can make a Web application work offline without an Internet connection. All browsers, besides IE, can use  _AppCache_  (at this point in time). - -The advantages of Application Cache are: - -* Enables browsing Web pages offline - -* Pages load faster - -* Results in less load for servers - -The  _cache manifest_  file is a simple text file that lists the resources the browser should cache for offline access. The  _manifest_  attribute can be included on the document’s HTML tag, as follows: - -```...``<``/html``>` - -It should be on all the pages that you want to cache. - -The application pages that are cached will remain unless: - -1\. The user clears them out. -2\. The manifest has been modified. -3\. The cache is updated. - -**Video** - -Until HTML5 was launched, there was no uniform standard for showing video on Web pages. Most of the videos were shown through different plugins like Flash. But HTML5 specifies a standard way to show the video on a Web page by using a video element. - -Currently, it supports three video formats for the video element, as shown in Table 2. - - [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/table-2.jpg?resize=350%2C115)][9] -The example given below shows the use of this video element: - ```````