如何通过 shadowsocks 路由我的 SSH 流量?
我正在使用 shadowsocks 从防火墙后面连接到服务器。我想建立传出 SSH 连接,但我担心 SSH 流量可能会被识别,从而导致我的连接关闭。因此,我希望能够通过我已经使用的 SOCKS5 代理路由 SSH 流量。
我从哪里开始实现这一目标?我假设我需要创建一个虚拟网络适配器,该适配器可以提供一系列端口,从这些端口以某种方式通过 SOCKS5 代理路由输出?
如果你的shadowsocks配置是:
更改为您自己的配置
sudo apt install connect-proxy
Run Code Online (Sandbox Code Playgroud)
编辑你的 ~/.ssh/config
# Outside of the firewall, with HTTPS proxy
Host 42.42.42.42
ProxyCommand connect -H 127.0.0.1:1080 %h 22
## Inside the firewall (do not use proxy)
Host *
ProxyCommand connect %h %p
Run Code Online (Sandbox Code Playgroud)
现在你可以尝试:
ssh username@ipserver
Run Code Online (Sandbox Code Playgroud)
检查ip连接
netstat -tn 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
通常你可以看到类似的东西
Connexions Internet actives (sans serveurs)
Proto Recv-Q Send-Q Adresse locale Adresse distante Etat
tcp 0 68 69.69.69.69:22 42.42.42.42:42800 ESTABLISHED
Run Code Online (Sandbox Code Playgroud)
更多技能
将此脚本添加到您的 ~/.bash_profile.
袜子5
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
Run Code Online (Sandbox Code Playgroud)
或者
HTTP(S)
export http_proxy=http://127.0.0.1:1080
export https_proxy=https://127.0.0.1:1080
Run Code Online (Sandbox Code Playgroud)
如果您想为您的网络浏览器设置网络连接
桂路(侏儒)
或者只是将所有代理重定向添加到您的环境中
环境 | grep -i 代理
必须返回
HTTP_PROXY=http://127.0.0.1:1080/
FTP_PROXY=http://127.0.0.1:1080/
ALL_PROXY=socks://127.0.0.1:1080/
NO_PROXY=127.0.0.1,localhost
HTTPS_PROXY=http://127.0.0.1:1080/
https_proxy=http://127.0.0.1:1080/
http_proxy=http://127.0.0.1:1080/
no_proxy=127.0.0.1,localhost
all_proxy=socks://127.0.0.1:1080/
ftp_proxy=http://127.0.0.1:1080/
Run Code Online (Sandbox Code Playgroud)
如果您只想通过 shadowsocks 进行配置卷曲
export socks5=socks5://127.0.0.1:1080
Run Code Online (Sandbox Code Playgroud)
和
curl api.ipify.org
Run Code Online (Sandbox Code Playgroud)
对于 Git
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4534 次 |
最近记录: |