思路:在 客户端 上先创建一个 SOCKS 代理服务器,然后再使用 SSH 反向隧道将其暴露给服务器。
1 在客户端创建一个 SOCKS 代理服务器
ssh -D 1080 localhost
2 在客户端上启动反向 SSH 隧道
ssh -R 9999:localhost:1080 user@server -p21101
或者用ssh软件
3 在服务器上配置使用这个 SOCKS 代理
以 curl 为例:
curl --socks5 localhost:9999 baidu.com
这会让 curl 通过服务器的 9999 端口(实际上连接到客户端的 SOCKS 代理)来网络请求
也可以设置环境变量:
export ALL_PROXY=socks5://127.0.0.1:9999
# 然后测试用代理下东西
curl baidu.com
python3.10 -m pip install vllm -i https://pypi.mirrors.ustc.edu.cn/simple