前言

作为一名程序猿科学上网很重要,毕竟要查些资料或者问题,代码之类的都需要使用到Google,但是国内除了高校能默认支持访问Google的服务外,基本所有人想使用Google的服务都需要借助虚拟专用网VPN(Virtual Private Network)工具。为了能正常使用Google的资源以及考虑到数据访问的私密性和方便,就考虑搭建一个私人的VPN服务。

购买主机服务VPS并登录

我买的是搬瓦工的, 因为支持支付宝,网上有很多搬瓦工的购买流程,可以自行百度,然后可以参考该文的登录搬瓦工VPS流程:Windows/Mac/Linux如何SSH远程连接/登陆搬瓦工,在这就不细说了。

安装SSR脚本

原来的搬瓦工控制面板左下方自带了Open VPN以及Shadowsocks的一键安装的,但最新的被取消了,所以要手动安装 Shadowsocks ,至于为什么我不安装Open VPN 因为我们公司用的就是Open VPN,所以我想换个新的尝试。重点来了,大神出品的 Shadowsocks 一键安装脚本,强无敌,附github地址:https://github.com/iMeiji/shadowsocks_install/tree/master

安装起来很方便,分三步:
第一步:wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
第二步:chmod +x shadowsocks.sh
第三步:./shadowsocks.sh 2>&1 | tee shadowsocks.log
然后就进入选择界面,不懂的话直接一路回车选择默认选项即可。

You choose = Shadowsocks-Python
//输入密码
Please enter password for Shadowsocks-Python
(Default password: teddysun.com):123456

password = 123456
//输入端口
Please enter a port for Shadowsocks-Python [1-65535]
(Default port: 10594):10594

port = 10594

特别注意,由于Iphone 端的 Wingy 目前只支持 cfb,所以选择加密的时候选 aes-256-cfb,即7,回车

Congratulations, Shadowsocks-python server install completed!
Your Server IP        :  xxx.xxx.xxx.xxx 
Your Server Port      :  10594
Your Password         :  123456 
Your Encryption Method:  aes-256-cfb 
Welcome to visit:https://teddysun.com/342.html
Enjoy it!

看到上述信息,就代表已经安装成功啦!要保存好你的IP、Port 、Password、Encryption Method,就可以在不同的设备终端找到相应的SS进行安装设置使用了。

Shadowsocks 终端地址

Windows

https://github.com/shadowsocks/shadowsocks-windows/releases

Mac

https://github.com/yangfeicheung/Shadowsocks-X/releases

Android

https://github.com/shadowsocks/shadowsocks-android/releases

iPhone

  • Kite Ass Proxy:https://apps.apple.com/cn/app/kite-ss-proxy/id1346595633
  • First Wingy:https://apps.apple.com/cn/app/firstwingy/id1316416848
  • Super Wingy:https://apps.apple.com/cn/app/superwingy/id1290093815
  • Sockswitch:https://apps.apple.com/us/app/sockswitch-shadowsocks-client/id1453207024

另外单独附 Shadowsocks Github地址:https://github.com/shadowsocks/shadowsocks/tree/master

卸载

使用root用户登录,运行以下命令:

./shadowsocks.sh uninstall

配置文件

单用户配置文件

vi /etc/shadowsocks.json

{
    "server":"0.0.0.0",
    "server_port":10594,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"123456",
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open":false
}

多用户多端口配置文件

vi /etc/shadowsocks.json

{
    "server":"0.0.0.0",
    "local_address":"127.0.0.1",
    "local_port":1080,
    "port_password":{
         "10594":"123456",
         "10595":"abcdef",
         "9004":"a123456",
    }
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open":false
}

注意:如果你想修改密码,可以在此文件里修改并保存,然后重启 shadowsocks 即可,若不知道怎么重启 shadowsocks ,重启VPS主机也可,新密码就会生效

命令

启动:/etc/init.d/shadowsocks start
停止:/etc/init.d/shadowsocks stop
重启:/etc/init.d/shadowsocks restart
状态:/etc/init.d/shadowsocks status
写入自启:echo "ssserver -c /etc/shadowsocks.json -d restart" >> /etc/rc.local
查看日志:less /var/log/shadowsocks.log
从Shadowsocks2.6开始,你可以直接在后台运行Shadowsocks,无需Supervisor.这样省掉了Supervisor进程占用的内存。
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
ssserver -c /etc/shadowsocks.json -d restart

查看连接的人数

Ubuntu:apt-get install lsof -y
CentOs:yum install lsof -y

#假设服务器端口10594, 查看连接数
sudo lsof -i -n -P | egrep -c ':10594.+ESTABLISHED'

#查看连接列表
sudo lsof -i -n -P | egrep ':10594.+ESTABLISHED'
最后修改:2023 年 09 月 11 日
如果觉得我的文章对你有用,请随意赞赏