一、安装python-pip
系统为: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210224
apt-get install python-pip
有时我们直接安装python-pip会出现错误
此时需要我们先执行下 update
apt-get update
然后在执行安装就可以了
二、安装shadowsocks
安装命令
pip install git+https://github.com/shadowsocks/shadowsocks.git@master
安装后,我们可以通过ssserver –version查看版本信息
三、配置shadowsocks
启动编辑
vi /etc/shadowsocks.json
输入以下内容
{
"server":"0.0.0.0",
"server_port":443,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"123456789",
"timeout":300,
"method":"aes-256-gcm",
"fast_open": true
}
- server,你的VPS服务器的IP地址
- server_port,你的shadowsocks服务端口。一般可以填一个1025到49151之间的数字。不过如果使用一个知名端口,比如25(电子邮件)、21(FTP),“可能”会更安全,因为GFW对这些基础互联网服务下手的可能性似乎会小一些。注意不要和你的VPS上已经有的服务冲突。
- local_address,本地IP地址,作为服务器使用的时候可以不用关注,填127.0.0.1即可。
- local_port,本地端口,也不用关注。
- password,你的shadowsocks服务密码,客户端连接时需要填写的。
- timeout,超时时间,如果当心网络不好可以设置大一点。
- method,加密方式,建议填写aes-256-cfb,安全性比较高。
- fast_open,在Ubuntu上建议填True。
四、启动
# 启动
ssserver -c /etc/shadowsocks.json -d start
# 停止
ssserver -c /etc/shadowsocks.json -d stop
# 重启
ssserver -c /etc/shadowsocks.json -d restart
# 查询进程
ps -ef | grep ssserver | grep -v ps | grep -v grep
五、定时重启
crontab -u root -e
然后在编辑器输入 0 0 1 * * /etc/init.d/shadowsocks restart
说明是第一次运行该命令,这里是让选择编译器的意思,喜欢用vim的童鞋可以选择3。
补充两点:
- 如果选择了2,那个nano编辑器,可以按ctrl+x退出。
- 如果不小心选择了2,那么又想改回vim怎么办呢?运行这个命令