系統版本:ubuntu18.0.4
參考地址:
https://blog.csdn.net/blackfrog_unique/article/details/60320737
1. 安裝Shadowsocks
# 獲取root權限
sudo -s
# 更新apt-get
apt-get update
# 安裝python包管理工具
apt-get install python-setuptools
apt-get install python-pip
# 安裝shadowsocks
pip install shadowsocks
2. 配置Shadowsocks
mkdir /etc/shadowsocks
vim /etc/shadowsocks/ss.json
配置文件如下
{
"server": "0.0.0.0",
"server_port": 443, #自定義端口
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "你的密碼",
"timeout": 300,
"method": "aes-256-cfb",
"workers": 1
}
3. 啓動shadownsocks
# 啓動
ssserver -c /etc/shadowsocks/ss.json -d start
# 停止
ssserver -c /etc/shadowsocks/ss.json -d stop
# 重啓
ssserver -c /etc/shadowsocks/ss.json -d restart
4. 設置開機啓動
vim /etc/rc.local
ssserver -c /etc/shadowsocks/ss.json -d star
5. 遇到的問題
5.1 啓動報錯
錯誤信息如下:
INFO: loading config from ss.json
2016-12-14 22:47:50 INFO loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
File “/usr/local/bin/sslocal”, line 11, in
sys.exit(main())
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/local.py”, line 39, in main
config = shell.get_config(True)
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 262, in get_config
check_config(config, is_local)
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 124, in check_config
encrypt.try_cipher(config[‘password’], config[‘method’])
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 44, in try_cipher
Encryptor(key, method)
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 83, in init
random_string(self._method_info[1]))
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 109, in get_cipher
return m[2](method, key, iv, op)
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 76, in init
load_openssl()
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File “/usr/lib/python2.7/ctypes/init.py”, line 375, in getattr
func = self.getitem(name)
File “/usr/lib/python2.7/ctypes/init.py”, line 380, 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
這個問題是由於在openssl1.1.0版本中,廢棄了EVP_CIPHER_CTX_cleanup函數,如官網中所說:
EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result, EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared.
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().
修改方法:
-
用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配置文件目錄
問題解決
5.2 配置安全組
- 一切就緒發現無法使用,查看後爲端口未開放,打開aws控制檯配置安全組開放對應端口