版权声明:本文为博主夏日辉的原创文章,未经博主允许不得转载。 https://blog.csdn.net/shanpenghui/article/details/91491239
- 安装ss
sudo apt-get update
sudo apt-get install python-pip
sudo pip install shadowsocks
- 配置json文件
sudo gedit /etc/shadowsocks.json
将下面内容添加到文件中,括号的内容可以删除,注意格式,否则会报错:
{
"server": "(服务器地址,比如)1.1.1.1",
"server_port": (服务器端口号,比如)8080,
"local_port": (本地端口号,比如)1080,
"password": "(服务器密码,比如)skqhfsaoqou",
"timeout": (超时时间,比如)300,
"method": "aes-256-cfb"
}
- 启动
本地客户端(作为客户端链接你的服务器):
sudo sslocal -c /etc/shadowsocks.json -d start
本地服务器(作为服务器):
sudo ssserver -c /etc/shadowsocks.json -d start
- 出错解决办法:
正常来说,一般会出现下面错误:
Traceback (most recent call last):
File "/usr/bin/ssserver", line 9, in
load_entry_point('shadowsocks==2.8.2', 'console_scripts', 'ssserver')()
File "/usr/lib/python2.7/site-packages/shadowsocks/server.py", line 34, in main
config = shell.get_config(False)
File "/usr/lib/python2.7/site-packages/shadowsocks/shell.py", line 262, in get_config
check_config(config, is_local)
File "/usr/lib/python2.7/site-packages/shadowsocks/shell.py", line 124, in check_config
encrypt.try_cipher(config['password'], config['method'])
File "/usr/lib/python2.7/site-packages/shadowsocks/encrypt.py", line 44, in try_cipher
Encryptor(key, method)
File "/usr/lib/python2.7/site-packages/shadowsocks/encrypt.py", line 83, in __init__
random_string(self._method_info[1]))
File "/usr/lib/python2.7/site-packages/shadowsocks/encrypt.py", line 109, in get_cipher
return m[2](method, key, iv, op)
File "/usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
load_openssl()
File "/usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File "/usr/lib64/python2.7/ctypes/__init__.py", line 373, in __getattr__
func = self.__getitem__(name)
File "/usr/lib64/python2.7/ctypes/__init__.py", line 378, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/ssl/lib/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
shadowsocks start failed
原因是在openssl1.1.0版本中,废弃了EVP_CIPHER_CTX_cleanup函数。参考官网:https://www.openssl.org/docs/man1.1.0/crypto/EVP_EncryptInit.html#HISTORY
解决办法:
1.打开错误提示中的文件:
sudo gedit /usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py
2.(全文件共2处)搜索(Ctrl+F)cleanup
找到libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
将其改为libcrypto.EVP_CIPHER_CTX_reset.argtypes = (c_void_p,)
3.再次搜索cleanup,将libcrypto.EVP_CIPHER_CTX_cleanup(self._ctx)
改为libcrypto.EVP_CIPHER_CTX_reset(self._ctx)
4.保存并推出(Ctrl+S)
- 设置开机启动:
sudo gedit /etc/rc.local
将
sslocal -c /etc/shadowsocks.json -d start
添加到该文件中