#!/bin/bash
# 安装Trojan客户端
echo "开始安装Trojan客户端..."
curl -O https://github.com/trojan-gfw/trojan/releases/download/v1.17.0/trojan-1.17.0-linux-amd64.tar.xz
tar xf trojan-1.17.0-linux-amd64.tar.xz
cd trojan make install
# 配置Trojan客户端
echo "开始配置Trojan客户端..."
mkdir /etc/trojan
cat > /etc/trojan/config.json <<EOF
{
"run_type": "client",
"local_addr": "127.0.0.1",
"local_port": 1080,
"remote_addr":
"your_server_ip",
"remote_port": 443,
"password": [
"your_password"
],
"log_level": 1,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "/etc/trojan/client.crt",
"key": "/etc/trojan/client.key",
"sni": "your_domain_name"
},
"dns": {
"servers": [
"8.8.8.8",
"8.8.4.4"
],
"over_tls": true,
"over_tcp": false,
"prefer_ipv6": false,
"timeout": 10
}
}
EOF
# 生成证书
echo "开始生成证书..."
openssl req -newkey rsa:2048 -nodes -keyout /etc/trojan/client.key -x509 -days 365 -out /etc/trojan/client.crt <<EOF
US
CA
San Francisco
Cloud
IT
your_domain_name
root@your_domain_name
EOF
# 启动Trojan客户端
echo "启动Trojan客户端..."
trojan -c /etc/trojan/config.json echo "安装和配置Trojan客户端完成!"
该脚本会自动下载、编译、安装trojan客户端,并在/etc/trojan目录下生成配置文件config.json和证书client.crt、client.key,并启动trojan客户端。 请注意替换其中的your_server_ip、your_password、your_domain_name等参数为你自己的信息