Conoha搭建shadowsocks服務端 教程
阿新 • • 發佈:2018-12-08
本文記錄了我自己搭建2.6.8的過程。
這裡介紹的是使用皮普作為管理軟體對2.6.8進行管理,所以我們應該首先安裝一下點子。
安裝PIP
pip的安裝這裡參考官網 - 安裝,即,輸入curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
後回車,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]
</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py</span> <span style="color:#f8f8f2">%</span> <span style="color:#a6e22e">Total</span> <span style="color:#f8f8f2">%</span> <span style="color:#a6e22e">Received</span> <span style="color:#f8f8f2">%</span> <span style="color:#a6e22e">Xferd</span> <span style="color:#a6e22e">Average</span> <span style="color:#a6e22e">Speed</span> <span style="color:#a6e22e">Time</span> <span style="color:#a6e22e">Time</span> <span style="color:#a6e22e">Time</span> <span style="color:#a6e22e">Current</span> <span style="color:#a6e22e">Dload</span> <span style="color:#a6e22e">Upload</span> <span style="color:#a6e22e">Total</span> <span style="color:#a6e22e">Spent</span> <span style="color:#a6e22e">Left</span> <span style="color:#a6e22e">Speed</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">1604k</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">1604k</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">11.1M</span> <span style="color:#ae81ff">0</span> <span style="color:#f8f8f2">--:--:--</span> <span style="color:#f8f8f2">--:--:--</span> <span style="color:#f8f8f2">--:--:--</span> <span style="color:#ae81ff">11.2M</span></code></span>
然後,輸入側python get-pip.py
之後回車,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># python get-pip.py</span>
<span style="color:#a6e22e">Collecting</span><span style="color:#66d9ef"> pip
</span><span style="color:#a6e22e">Downloading</span><span style="color:#66d9ef"> https</span><span style="color:#f8f8f2">:</span><span style="color:#93a1a1">//files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)</span>
<span style="color:#ae81ff">100</span><span style="color:#f8f8f2">%</span> <span style="color:#f8f8f2">|████████████████████████████████|</span> <span style="color:#ae81ff">1.3MB</span> <span style="color:#ae81ff">11.3MB</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">s
</span><span style="color:#a6e22e">Collecting</span><span style="color:#66d9ef"> wheel
</span><span style="color:#a6e22e">Downloading</span><span style="color:#66d9ef"> https</span><span style="color:#f8f8f2">:</span><span style="color:#93a1a1">//files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)</span>
<span style="color:#ae81ff">100</span><span style="color:#f8f8f2">%</span> <span style="color:#f8f8f2">|████████████████████████████████|</span> <span style="color:#ae81ff">51kB</span> <span style="color:#ae81ff">17.5MB</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">s
</span><span style="color:#a6e22e">Installing</span><span style="color:#66d9ef"> collected packages</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> pip</span><span style="color:#f8f8f2">,</span><span style="color:#66d9ef"> wheel
</span><span style="color:#a6e22e">Successfully</span><span style="color:#66d9ef"> installed pip</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">18.0</span><span style="color:#66d9ef"> wheel</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">0.31</span><span style="color:#f8f8f2">.</span><span style="color:#ae81ff">1</span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef"> [email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
</code></span>
安裝2.6.8
輸入側pip install shadowsocks
後回車,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># pip install shadowsocks</span>
<span style="color:#a6e22e">Collecting</span><span style="color:#66d9ef"> shadowsocks
</span><span style="color:#a6e22e">Downloading</span><span style="color:#66d9ef"> https</span><span style="color:#f8f8f2">:</span><span style="color:#93a1a1">//files.pythonhosted.org/packages/02/1e/e3a5135255d06813aca6631da31768d44f63692480af3a1621818008eb4a/shadowsocks-2.8.2.tar.gz</span>
<span style="color:#a6e22e">Building</span><span style="color:#66d9ef"> wheels </span><span style="color:#f92659">for</span><span style="color:#66d9ef"> collected packages</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> shadowsocks
</span><span style="color:#a6e22e">Running</span><span style="color:#66d9ef"> setup</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">py bdist_wheel </span><span style="color:#f92659">for</span><span style="color:#66d9ef"> shadowsocks </span><span style="color:#f8f8f2">...</span> <span style="color:#f92659">done</span>
<span style="color:#a6e22e">Stored</span> <span style="color:#f92659">in</span><span style="color:#66d9ef"> directory</span><span style="color:#f8f8f2">:</span> <span style="color:#e6db74">/root/</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">cache</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">pip</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">wheels</span><span style="color:#f8f8f2">/</span><span style="color:#ae81ff">5e</span><span style="color:#f8f8f2">/</span><span style="color:#ae81ff">8d</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">b6</span><span style="color:#f8f8f2">/</span><span style="color:#ae81ff">3e2243a7e116984b2c3597c122c29abcfeac77daa260079e88</span>
<span style="color:#a6e22e">Successfully</span><span style="color:#66d9ef"> built shadowsocks
</span><span style="color:#a6e22e">Installing</span><span style="color:#66d9ef"> collected packages</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> shadowsocks
</span><span style="color:#a6e22e">Successfully</span><span style="color:#66d9ef"> installed shadowsocks</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">2.8</span><span style="color:#f8f8f2">.</span><span style="color:#ae81ff">2</span></code></span>
提示安裝成功!
配置2.6.8
編輯輸入側檔案命令vi /etc/shadowsocks.json
並回車,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># vi /etc/shadowsocks.json</span></code></span>
上述步驟是編輯一個新檔案,鍵盤按i
鍵後,貼上下面內容:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">{</span>
<span style="color:#e6db74">"server"</span><span style="color:#f8f8f2">:</span><span style="color:#e6db74">"0.0.0.0"</span><span style="color:#f8f8f2">,</span>
<span style="color:#e6db74">"server_port"</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">50013</span><span style="color:#f8f8f2">,</span>
<span style="color:#e6db74">"local_port"</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">1080</span><span style="color:#f8f8f2">,</span>
<span style="color:#e6db74">"password"</span><span style="color:#f8f8f2">:</span><span style="color:#e6db74">"1234567890"</span><span style="color:#f8f8f2">,</span>
<span style="color:#e6db74">"timeout"</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">600</span><span style="color:#f8f8f2">,</span>
<span style="color:#e6db74">"method"</span><span style="color:#f8f8f2">:</span><span style="color:#e6db74">"aes-256-cfb"</span>
<span style="color:#f8f8f2">}</span>
</code></span>
然後按鍵盤Esc鍵鍵,再按shift+:
鍵,輸入側再wq
並回車。檔案編輯結束。
上面的50013是你的伺服器埠,1234567890是你進行連線的密碼。
將2.6.8加入系統服務
編輯輸入側檔案命令vi /etc/systemd/system/shadowsocks.service
並回車,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># vi /etc/systemd/system/shadowsocks.service</span></code></span>
鍵盤按i
鍵後,貼上下面內容:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#a6e22e">Unit</span><span style="color:#f8f8f2">]</span>
<span style="color:#a6e22e">Description</span><span style="color:#f8f8f2">=</span><span style="color:#a6e22e">Shadowsocks</span>
<span style="color:#f8f8f2">[</span><span style="color:#a6e22e">Service</span><span style="color:#f8f8f2">]</span>
<span style="color:#a6e22e">TimeoutStartSec</span><span style="color:#f8f8f2">=</span><span style="color:#ae81ff">0</span>
<span style="color:#a6e22e">ExecStart</span><span style="color:#f8f8f2">=</span><span style="color:#e6db74">/usr/</span><span style="color:#66d9ef">bin</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">ssserver </span><span style="color:#f8f8f2">-</span><span style="color:#66d9ef">c </span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">etc</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">json
</span><span style="color:#f8f8f2">[</span><span style="color:#a6e22e">Install</span><span style="color:#f8f8f2">]</span>
<span style="color:#a6e22e">WantedBy</span><span style="color:#f8f8f2">=</span><span style="color:#66d9ef">multi</span><span style="color:#f8f8f2">-</span><span style="color:#66d9ef">user</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">target</span></code></span>
然後按鍵盤Esc鍵鍵,再按shift+:
鍵,輸入側再wq
並回車。檔案編輯結束。
啟動2.6.8服務並設定開機自啟
<span style="color:#f8f8d4"><code><span style="color:#93a1a1"># 設定開機自啟命令</span><span style="color:#66d9ef">
systemctl enable shadowsocks
</span><span style="color:#93a1a1"># 啟動命令</span><span style="color:#66d9ef">
systemctl start shadowsocks
</span><span style="color:#93a1a1">#檢視狀態命令</span><span style="color:#66d9ef">
systemctl status shadowsocks</span></code></span>
依次執行上面的三條命令,如下:
<span style="color:#f8f8d4"><code><span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># vi /etc/shadowsocks.json</span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># vi /etc/systemd/system/shadowsocks.service</span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># </span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># systemctl enable shadowsocks</span>
<span style="color:#a6e22e">Created</span><span style="color:#66d9ef"> symlink </span><span style="color:#f92659">from</span> <span style="color:#f8f8f2">/</span><span style="color:#66d9ef">etc</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">systemd</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">system</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">multi</span><span style="color:#f8f8f2">-</span><span style="color:#66d9ef">user</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">target</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">wants</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">service to </span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">etc</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">systemd</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">system</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">service</span><span style="color:#f8f8f2">.</span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># systemctl start shadowsocks</span>
<span style="color:#f8f8f2">[</span><span style="color:#66d9ef">[email protected]</span> <span style="color:#f8f8f2">~]</span><span style="color:#93a1a1"># systemctl status shadowsocks</span>
<span style="color:#f8f8f2">●</span><span style="color:#66d9ef"> shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">service </span><span style="color:#f8f8f2">-</span> <span style="color:#a6e22e">Shadowsocks</span>
<span style="color:#a6e22e">Loaded</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> loaded </span><span style="color:#f8f8f2">(</span><span style="color:#e6db74">/etc/</span><span style="color:#66d9ef">systemd</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">system</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">service</span><span style="color:#f8f8f2">;</span><span style="color:#66d9ef"> enabled</span><span style="color:#f8f8f2">;</span><span style="color:#66d9ef"> vendor preset</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> disabled</span><span style="color:#f8f8f2">)</span>
<span style="color:#a6e22e">Active</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> active </span><span style="color:#f8f8f2">(</span><span style="color:#66d9ef">running</span><span style="color:#f8f8f2">)</span><span style="color:#66d9ef"> since </span><span style="color:#a6e22e">Tue</span> <span style="color:#ae81ff">2018</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">08</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">53</span><span style="color:#66d9ef"> UTC</span><span style="color:#f8f8f2">;</span> <span style="color:#ae81ff">7s</span><span style="color:#66d9ef"> ago
</span><span style="color:#a6e22e">Main</span><span style="color:#66d9ef"> PID</span><span style="color:#f8f8f2">:</span> <span style="color:#ae81ff">1259</span> <span style="color:#f8f8f2">(</span><span style="color:#66d9ef">ssserver</span><span style="color:#f8f8f2">)</span>
<span style="color:#a6e22e">CGroup</span><span style="color:#f8f8f2">:</span> <span style="color:#e6db74">/system.slice/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">service
</span><span style="color:#f8f8f2">└─</span><span style="color:#ae81ff">1259</span> <span style="color:#f8f8f2">/</span><span style="color:#66d9ef">usr</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">bin</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">python </span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">usr</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">bin</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">ssserver </span><span style="color:#f8f8f2">-</span><span style="color:#66d9ef">c </span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">etc</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">json
</span><span style="color:#a6e22e">Aug</span> <span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">53</span><span style="color:#66d9ef"> ssserver systemd</span><span style="color:#f8f8f2">[</span><span style="color:#ae81ff">1</span><span style="color:#f8f8f2">]:</span> <span style="color:#a6e22e">Started</span> <span style="color:#a6e22e">Shadowsocks</span><span style="color:#f8f8f2">.</span>
<span style="color:#a6e22e">Aug</span> <span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">53</span><span style="color:#66d9ef"> ssserver systemd</span><span style="color:#f8f8f2">[</span><span style="color:#ae81ff">1</span><span style="color:#f8f8f2">]:</span> <span style="color:#a6e22e">Starting</span> <span style="color:#a6e22e">Shadowsocks</span><span style="color:#f8f8f2">...</span>
<span style="color:#a6e22e">Aug</span> <span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">54</span><span style="color:#66d9ef"> ssserver ssserver</span><span style="color:#f8f8f2">[</span><span style="color:#ae81ff">1259</span><span style="color:#f8f8f2">]:</span><span style="color:#66d9ef"> INFO</span><span style="color:#f8f8f2">:</span><span style="color:#66d9ef"> loading config </span><span style="color:#f92659">from</span> <span style="color:#f8f8f2">/</span><span style="color:#66d9ef">etc</span><span style="color:#f8f8f2">/</span><span style="color:#66d9ef">shadowsocks</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">json
</span><span style="color:#a6e22e">Aug</span> <span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">54</span><span style="color:#66d9ef"> ssserver ssserver</span><span style="color:#f8f8f2">[</span><span style="color:#ae81ff">1259</span><span style="color:#f8f8f2">]:</span> <span style="color:#ae81ff">2018</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">08</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">54</span><span style="color:#66d9ef"> INFO loading libcrypto </span><span style="color:#f92659">from</span><span style="color:#66d9ef"> libcrypto</span><span style="color:#f8f8f2">.</span><span style="color:#66d9ef">so</span><span style="color:#f8f8f2">.</span><span style="color:#ae81ff">10</span>
<span style="color:#a6e22e">Aug</span> <span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">54</span><span style="color:#66d9ef"> ssserver ssserver</span><span style="color:#f8f8f2">[</span><span style="color:#ae81ff">1259</span><span style="color:#f8f8f2">]:</span> <span style="color:#ae81ff">2018</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">08</span><span style="color:#f8f8f2">-</span><span style="color:#ae81ff">28</span> <span style="color:#ae81ff">13</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">27</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">54</span><span style="color:#66d9ef"> INFO starting server at </span><span style="color:#ae81ff">0.0</span><span style="color:#f8f8f2">.</span><span style="color:#ae81ff">0.0</span><span style="color:#f8f8f2">:</span><span style="color:#ae81ff">50013</span>
</code></span>
這樣shadowsocks服務端就安裝並啟動成功,接下來進行客戶端的連線使用就可以了,客戶端下載地址:安卓/ Android / Windows / IOS /蘋果手機Shadowsocks最新版下載地址。
客戶端配置
當你的服務端搭建完成之後,你需要根據你服務端的配置,進行客戶端的相應配置,具體參考下面的配置項:
補充
1.失敗原因排查
- 服務端服務未啟動;
- 遠端VPS伺服器埠未開啟;