思路:在 客戶端 上先創建一個 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