搭建 shadowsocks 服务

搬瓦工 VPS 购买流程

配置
SSD 10 GB
RAM 512 MB
CPU 1x Intel Xeon
BW 1000 GB
  • 选择购买时长:一个月/季度/一年
  • 确认添加购物车
  • [创建账号并且]提交订单
  • 支付(支持支付宝)

搬瓦工 VPS 安装 Centos 6 x86_64 系统

  • 点击”KiwiVM Control Panel” 进入VPS管理台

  • 准备重新安装Centos 6 x86_64系统,右侧 Actions:Stop 按钮停止VPN服务器.

  • 点击左边菜单 Install new OS,选择系统”Centos 6 x86_64” 安装.

  • 根据页面给出的 ssh 端口和 root 密码登录 vps 系统

CentOS 6 Python2.66 升级2.7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 查看python 版本
python --version
# 安装 gcc
yum install -y gcc
# 安装 python 工具需要的额外软件包 SSL, bz2, zlib
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
# 下载Python-2.7.9
cd /tmp
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
tar -xvf Python-2.7.9.tar.xz
cd Python-2.7.9
# 编译安装
./configure --prefix=/usr/local/python27
make && make install
# 备份老的python 版本
mv /usr/bin/python /usr/bin/python266
# 软连新版本 2.7.9
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
# 解决yum 无法运行(centos中yum需要引用的是python老版本2.6)
vim /usr/bin/yum
> #!/usr/bin/python
替换为:
> #!/usr/bin/python266
# 安装 pip
cd /tmp
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
# python的bin目录加入环境变量
vi /etc/profile.d/python_path.sh
> export PATH="/usr/local/python27/bin:$PATH"
# 重新加载环境变量
source /etc/profile

Shadowsocks 服务端安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 安装
pip install shadowsocks
# 创建目录保存配置文件
mkdir -p /home/shadowsocks
vi /home/shadowsocks/config.json
# 输入配置内容
{
"server":"0.0.0.0",
"server_port":8388,
"local_port":1080,
"password":"修改为你想设置的密码",
"timeout":600,
"method":"aes-256-cfb",
"auth": true
}
# 启动服务
ssserver -c /home/shadowsocks/config.json -d start
# 停止服务
ssserver -c /home/shadowsocks/config.json -d stop

创建一个登录系统的用户

1
2
3
4
5
6
7
8
9
10
11
12
13
useradd louis
# 设置密码
passwd louis
# 将该用户授予超级权限
visudo
# 找到下面文字行
> ## Allow root to run any commands anywhere
>root ALL=(ALL) ALL
修改为:
> ## Allow root to run any commands anywhere
>root,louis ALL=(ALL) ALL

为安全起见,禁用root帐号登陆

1
2
3
4
5
6
7
8
9
vi /etc/ssh/sshd_config
#找到 PermitRootLogin yes 修改为
PermitRootLogin no
#重启服务
service sshd restart
# 退出后就只能用刚刚创建的帐号登录了,root 被禁止登录

引用

shadowsocks 官网安装说明

https://shadowsocks.org/en/download/servers.html