Ubuntu 18.04 安裝SS以及遇見的問題
阿新 • • 發佈:2018-12-15
安裝並配置SS
[email protected]:/etc/shadowsocks$ sudo apt install shadowsocks
[email protected]:/etc/shadowsocks$ cat /etc/shadowsocks/config.json
{
"server":"serverIP",
"server_port":443,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"**************",
"timeout":600,
"method":"rc4-md5",
"fast_open": false,
"workers": 1,
"prefer_ipv6": false
}
[email protected]:/etc/shadowsocks$
[email protected]:~/opt$ sslocal -c /etc/shadowsocks/config.json
由於/etc/shadowsocks/config.json是sslocal的預設配置檔案,所以,也可以不用加-c引數,直接執行sslocal。
以守護程序形式執行客戶端
注意: shadowsocks和shadowsocks-libev的systemd 系統單元使用相同的配置檔案路徑 (/etc/shadowsocks) Shadowsocks的systemd服務可在/etc/shadowsocks/裡呼叫不同的conf-file.json(以conf-file為區分標誌),例: 在/etc/shadowsocks/中建立了foo.json配置檔案,那麼執行以下語句就可以呼叫該配置:
#systemctl start [email protected]
若需開機自啟動:
#systemctl enable [email protected]
遇見的問題
[email protected]:/etc/shadowsocks$ sslocal
INFO: loading config from config.json
2018-10-17 12:40:00 INFO loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
File "/usr/local/bin/sslocal", line 11, in <module>
load_entry_point('shadowsocks==2.8.2', 'console_scripts', 'sslocal')()
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/local.py", line 39, in main
config = shell.get_config(True)
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/shell.py", line 262, in get_config
check_config(config, is_local)
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/shell.py", line 124, in check_config
encrypt.try_cipher(config['password'], config['method'])
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/encrypt.py", line 44, in try_cipher
Encryptor(key, method)
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/encrypt.py", line 83, in __init__
random_string(self._method_info[1]))
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/encrypt.py", line 109, in get_cipher
return m[2](method, key, iv, op)
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/crypto/rc4_md5.py", line 33, in create_cipher
return openssl.OpenSSLCrypto(b'rc4', rc4_key, b'', op)
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
load_openssl()
File "/home/k/.local/lib/python3.6/site-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File "/usr/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
[email protected]:/etc/shadowsocks$
網上的修改方式一般是這樣:
- 用vim開啟檔案:vim /usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py (該路徑請根據自己的系統情況自行修改,如果不知道該檔案在哪裡的話,可以使用find命令查詢檔案位置) 跳轉到52行(shadowsocks2.8.2版本,其他版本搜尋一下cleanup)
- 進入編輯模式 將第52行libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,) 改為libcrypto.EVP_CIPHER_CTX_reset.argtypes = (c_void_p,)
- 再次搜尋cleanup(全檔案共2處,此處位於111行),將libcrypto.EVP_CIPHER_CTX_cleanup(self._ctx) 改為libcrypto.EVP_CIPHER_CTX_reset(self._ctx)
- 儲存並退出
- 啟動shadowsocks服務:service shadowsocks start 或 sslocal -c ss配置檔案目錄 問題解決
但其實我們可以在log中看到應該修改的是/home/k/.local/lib/python3.6/目錄下的檔案,思路一樣。
安裝polipo代理http
這是因為sslocal只支援socks5,並不支援http 。
sudo apt-get install polipo //安裝
sudo gedit /etc/polipo/config //配置
將下面的內容整個替換到檔案中並儲存:
# This file only needs to list configuration variables that deviate
# from the default values. See /usr/share/doc/polipo/examples/config.sample
# and "polipo -v" for variables you can tweak and further information.
logSyslog = false
logFile = "/var/log/polipo/polipo.log"
socksParentProxy = "127.0.0.1:1080"
socksProxyType = socks5
chunkHighMark = 50331648
objectHighMark = 16384
serverMaxSlots = 64
serverSlots = 16
serverSlots1 = 32
proxyAddress = "0.0.0.0"
proxyPort = 8123
作者:Danny的橙
連結:https://www.jianshu.com/p/725f978f1cfe
重啟Polipo:
/etc/init.d/polipo restart
驗證代理是否正常工作:
export http_proxy=”http://127.0.0.1:8123/”
curl www.google.com
如果正常,就會返回抓取到的Google網頁內容。 另外,在瀏覽器中輸入http://127.0.0.1:8123/便可以進入到Polipo的使用說明和配置介面。