sudo apt -y update && sudo apt -y upgrade
# 示例命令,请务必替换为最新的 URL!
#解压下载的文件
tar -xf shadowsocks-v*.tar.xz
# 将 ssserver 以及其他有用的工具(如 sslocal, ssurl)移动到 /usr/local/bin
sudo mv ssserver sslocal ssurl /usr/local/bin/
sudo mkdir /etc/shadowsocks-rust
sudo vim /etc/shadowsocks-rust/config.json
#将下面的 JSON 内容粘贴到文件中
{
"server": "::",
"server_port": 8388,
"password": "your_very_strong_password",
"method": "aes-256-gcm",
"mode": "tcp_and_udp"
}
#请务必修改:
- “server”: “::” 是一个推荐的设置,它会同时监听 IPv4 和 IPv6 地址。如果您确定只需要 IPv4,也可以使用 “0.0.0.0”。
- “server_port”: 您可以保持 8388 或更改为您喜欢的任何有效端口。
- “password”: 这是最重要的!请务必将其替换为您自己生成的、足够强大的密码。
- “method”: aes-256-gcm 是目前兼具安全和性能的绝佳选择。其他推荐的选项包括 chacha20-ietf-poly1305。
- “mode”: “tcp_and_udp” 确保同时支持 TCP 和 UDP 流量。
#编辑完成后,保存并退出(在 nano 中按 Ctrl + X,然后按 Y,再按 Enter)。
sudo vim /etc/systemd/system/shadowsocks-rust.service
#将以下内容复制并粘贴到文件中
[Unit] Description=shadowsocks-rust server After=network.target [Service] ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks-rust/config.json Restart=on-failure User=root [Install] WantedBy=multi-user.target
[Unit]
Description=shadowsocks-rust server
After=network.target
[Service]
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks-rust/config.json
Restart=on-failure
User=root
[Install]
WantedBy=multi-user.target
# 重新加载 systemd 配置,使其识别新服务
sudo systemctl daemon-reload
# 立即启动 shadowsocks-rust 服务
sudo systemctl start shadowsocks-rust
# 将服务设置为开机自启
sudo systemctl enable shadowsocks-rust
#检查服务状态
sudo systemctl status shadowsocks-rust