本地端口代理转发
首先,删除服务器上 ~/.bashrc 和 ~/.zshrc 与代理相关的所有内容。
在本地的~/.ssh/config 中进行 ssh 配置
[图片:SSH 配置示例]
注意这里的 RemotedForward,前面是服务器上的端口,后面是本地的代理端口,建议使用 http。
服务器代理端口配置
打开服务器上的~/.bashrc 和 ~/.zshrc,添加代理端口
zsh
export PROXY_PORT="18999"
proxy_on(){
export http_proxy="http://127.0.0.1:$PROXY_PORT"
export https_proxy="http://127.0.0.1:$PROXY_PORT"
export all_proxy="socks5://127.0.0.1:$PROXY_PORT"
export no_proxy="localhost,127.0.0.1,::1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,*.local,*.lan,*.cn"
if [ "$1" != "silent" ]; then
echo "Terminal Proxy [ON]: Tunneling to Local 1082 via 18999"
fi
}
proxy_off(){
unset http_proxy https_proxy all_proxy
echo "Terminal Proxy [OFF]"
}
proxy_on silent
bash
export http_proxy="http://127.0.0.1:18999"
export https_proxy="http://127.0.0.1:18999"
export all_proxy="socks5://127.0.0.1:18999"
export no_proxy="localhost,127.0.0.1,::1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12"

