Finalshell SSH连接工具下载
Mobaxterm SSH连接工具下载
1.服务器时间同步
设置硬件时钟调整为与本地时钟一致, 设置时区为上海 date -R 是查看服务器当前时间
centos7时间同步
1 2 3
| date -R timedatectl set-local-rtc 1 timedatectl set-timezone Asia/Shanghai
|
Debian系统同步时间如下:
1 2 3
| date -R rm -rf /etc/localtime cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
debian
安装依赖
1 2
| apt update apt install curl
|
centos7
安装依赖
1 2
| yum makecache yum install curl
|
2.安装dat和release.sh
1 2
| curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh
|
3.安装和更新V2Ray
安装v2ray输入如下内容
最近v2fly维护版本拉取最新数据输出如下内容 " + " 代表目前输出内容," - "代表在老版本基础上删除的信息
每行代码 " + " ," - "号忽略1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| +info: unzip is installed. +info: Extract the V2Ray package to /tmp/tmp.RS0y2YR2ZS/ and prepare it for installation. +installed: /usr/local/bin/v2ray +installed: /usr/local/bin/v2ctl +installed: /usr/local/lib/v2ray/geoip.dat +installed: /usr/local/lib/v2ray/geosite.dat +installed: /usr/local/etc/v2ray/config.json -installed: /usr/local/etc/v2ray/00_log.json -installed: /usr/local/etc/v2ray/01_api.json -installed: /usr/local/etc/v2ray/02_dns.json -installed: /usr/local/etc/v2ray/03_routing.json -installed: /usr/local/etc/v2ray/04_policy.json -installed: /usr/local/etc/v2ray/05_inbounds.json -installed: /usr/local/etc/v2ray/06_outbounds.json -installed: /usr/local/etc/v2ray/07_transport.json -installed: /usr/local/etc/v2ray/08_stats.json -installed: /usr/local/etc/v2ray/09_reverse.json -installed: /var/log/v2ray/ +installed: /var/log/v2ray/access.log +installed: /var/log/v2ray/error.log +installed: /etc/systemd/system/v2ray.service +installed: /etc/systemd/system/v2ray@.service +removed: /tmp/tmp.KojGXm19Pa/ +info: V2Ray v4.27.0 is installed.
|
4.安裝最新發行的geoip.dat和geosite.dat
1
| bash install-dat-release.sh
|
5.创建和编辑配置文件
在/usr/local/etc/v2ray下面创建一个新的config.json配置文件
复制以下代码到config.json
/usr/local/etc/v2ray1 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
| { "inbounds": [ { "port": 443, "protocol": "vmess", "settings": { "clients": [ { "id": "23ad6b10-8d1ae3e35cd38297", "alterId": 64 } ] }, "streamSettings": { "network": "tcp", "security": "tls", "tlsSettings": { "certificates": [ { "certificateFile": "/etc/v2ray/v2ray.crt", "keyFile": "/etc/v2ray/v2ray.key" } ] } } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] }
|
v2ray调试
1 2
| sudo systemctl restart v2ray sudo systemctl status -l v2ray
|
设置v2ray开机启动
6.生成证书
如果你已经有其他证书可忽略,把证书和密钥放到服务器指定目录下。申请证书方法太多可通过安装acme.sh工具生成证书或其他方法生成证书,可Google搜索。
1.安装acem.sh证书生成工具,以下提供3种方法安装,选其中任意一种方法安装证书工具 (温馨提示:自动升级acme.sh在root下输入 acme.sh upgrade)
/root/.acme.sh1 2 3 4 5 6 7
| curl https://get.acme.sh | sh // 如提示安装失败 请先安装curl 输入 yum -y install curl
wget -O - https://get.acme.sh | sh //如提示安装失败请(先安装wget)输入 yum -y install wget 已经安装了忽略
git clone https://github.com/acmesh-official/acme.sh.git // 如提示安装失败 先安装git 已经安装了的忽略 输入 yum install git cd ./acme.sh ./acme.sh --install
|
通过以上代码安装acme.sh提示红色
抱错 你可以按实际相关情况而定安装依赖 比如安装socat 或者 netcat
1 2 3 4 5 6 7
| centos7 yum install socat centos7 yum install netcat
debian apt-get install openssl cron socat curl debian apt-get -y install netcat
安装成功后执行 source ~/.bashrc
|
2.生成证书 路径为/root/.acme.sh文件下 安装好后可自行查看
温馨提示:通过acme.sh生成证书有多种方法:
例如—自动DNS API集成 如:cloudflare DNS API 令牌 和 使用全局API密钥 acme.sh支持大多数dns生成证书
例如—使用DNS手动模式,等多种其他安装方法,如果你是个好学的人可Google
生成证书如下:本期视频只用指定端口 生成证书 推荐使用443端口生成证书 (一般用单域名足以,毕竟是翻墙用无需搞那么多花里胡哨的多域,比如:主域baidu.com那么不建议使用 www.baidu.com 因为是翻墙的前端web请自定义比如tw.baidu.com,前缀tw可以自定义请不要写太长,主域baidu.com和二级 www.baidu.com 可以备用你懂的 )
1.通过侦听80端口申请证书,如果80端口被占用,请使用443端口,请确保这些端口都打开了
1
| sudo ~/.acme.sh/acme.sh --issue -d 域名 --standalone -k ec-256
|
2.如果您80在反向代理或负载均衡器后面使用非标准端口,则可以–httpport用来指定端口
1
| sudo ~/.acme.sh/acme.sh --issue -d 域名 --standalone --httpport 端口
|
3.侦听443端口以颁发证书,请确保443端口开启
1
| sudo ~/.acme.sh/acme.sh --issue -d 域名 --alpn -k ec-256
|
4.如果您443在反向代理或负载均衡器后面使用非标准端口,则可以–tlsport用来指定端口
1
| sudo ~/.acme.sh/acme.sh --issue -d 域名 --alpn --tlsport 端口
|
-k 表示密钥长度,后面的值可以是 ec-256 、ec-384、2048、3072、4096、8192,带有 ec 表示生成的是 ECC 证书,没有则是 RSA 证书。在安全性上 256 位的 ECC 证书等同于 3072 位的 RSA 证书
温馨提示:如何80或者443端口被占用导致我们无法申请密钥和证书,我们可以通过kill封杀端口在重新申请。
1 2 3 4 5 6 7 8
| netstat -tlnp|grep 80 或者 netstat -tlnp|grep 443 然后 kill 1103(这个1103是进程端口id)
如果终止不了,可以强制终止 kill -9 1103
|
7.证书和密钥安装到指定路径
/etc/v2ray (路径可自定义)
1 2 3
| ecc 安装代码 sudo ~/.acme.sh/acme.sh --installcert -d 域名 --fullchainpath /etc/v2ray/v2ray.crt --keypath /etc/v2ray/v2ray.key --ecc
rsa 安装代码 sudo ~/.acme.sh/acme.sh --installcert -d 域名 --fullchainpath /etc/v2ray/v2ray.crt --keypath /etc/v2ray/v2ray.key
|
將 /etc/v2ray/v2ray.key 修改為 644 权限
1
| chmod 644 /etc/v2ray/v2ray.key
|
8.BBr安装
1
| wget "https://raw.githubusercontent.com/ComeBey/rootfw-bbr/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
|
9.查询tls开启状态
https://www.ssllabs.com/ssltest/index.html 输入自己域名查询即可
关于config.json配置文件可以自己写,当然也包括其他各种负载均衡,反向代理。如果想短时间内提升自己的可以参加我的培训课。
10.如果想卸载V2Ray执行下面代码
1
| bash install-release.sh --remove
|
添加电报群