[英]How to Use sshuttle on Windows WSL2
We have a Jenkins server which is accessible only from within the VPC on the cloud.我们有一个 Jenkins 服务器,只能从云上的 VPC 内部访问。 On Mac and Linux I use
sshuttle
to make a ssh connection to the bastion instance (to act a proxy) and open the Jenkins console in the browser.在 Mac 和 Linux 上,我使用
sshuttle
与堡垒实例建立 ssh 连接(充当代理)并在浏览器中打开 Jenkins 控制台。 Everything works fine.一切正常。
Now I'm on Windows and trying to do the same on WSL2.现在我在 Windows 上,并试图在 WSL2 上做同样的事情。 If I'm not mistaken previously,
sshuttle
didn't work on WSL1 (failed with some error message), but I managed to run it on WSL2 without any issue.如果我之前没记错的话,
sshuttle
在 WSL1 上不起作用(失败并出现一些错误消息),但我设法在 WSL2 上运行它而没有任何问题。 The ssh connection is established and I can access my Jenkins (using curl
). ssh 连接已建立,我可以访问我的 Jenkins(使用
curl
)。
Then I tried to access my Jenkins on Windows via WSL2:然后我尝试通过 WSL2 在 Windows 上访问我的 Jenkins:
1. I found the IP address of WSL2 and the port the ssh tunnle: 1.我找到了WSL2的IP地址和端口ssh隧道:
# lsof -i -n | grep ssh
sshuttle 1234 rad 5u IPv4 39270 0t0 TCP *:socks (LISTEN)
ssh 5678 rad 3u IPv4 40252 0t0 TCP 172.25.236.84:57578->bastion:ssh (ESTABLISHED)
2. I configured network proxy setting of Firefox (v77) to use my ssh tunnle: 2. 我配置了 Firefox (v77) 的网络代理设置来使用我的 ssh 隧道:
Manual proxy configuration
SOCK host: 172.25.236.84
Port: 1080
SOCKS V5 (tested with V4 as well)
But loading the page fails with "The connection was reset" error on Firefox.但加载页面失败,Firefox 上出现“连接已重置”错误。 I tested via Powershell that the SOCKS port is open and responding (using
Test-NetConnection
).我通过 Powershell 测试了 SOCKS 端口已打开并响应(使用
Test-NetConnection
)。
1. Any idea what the problem is? 1.知道问题是什么吗? How to make it work?
如何让它发挥作用?
2. If it's not gonna work, is there any other solution (eg Docker, etc)? 2. 如果不行,是否有其他解决方案(例如 Docker 等)?
Thanks.谢谢。
I'm not sure, but my guess is that sshuttle
doesn't actually act as a SOCKS proxy and that's why the connection gets reset.我不确定,但我的猜测是
sshuttle
实际上并没有充当 SOCKS 代理,这就是连接被重置的原因。
I managed to access my Jenkins on Windows machine using ssh SOCKS proxy: ssh -D 0.0.0.0:1080 rad@bastion
and configured Firefox to use the SOCKS proxy. I managed to access my Jenkins on Windows machine using ssh SOCKS proxy:
ssh -D 0.0.0.0:1080 rad@bastion
and configured Firefox to use the SOCKS proxy.
Interestingly, for this you don't even need WSL.有趣的是,为此您甚至不需要 WSL。 It seems Windows 10 has OpenSSH and you can use it.
Windows 10 似乎有 OpenSSH,你可以使用它。 Just open CMD and type
ssh -D 1080 rad@bastion
and setup Firefox to use localhost as the proxy.只需打开 CMD 并输入
ssh -D 1080 rad@bastion
并设置 Firefox 以使用 localhost 作为代理。
If there's any better solution or any comment/concern (apart from DNS over SOCKS) with this approach, please share.如果有任何更好的解决方案或任何评论/关注(除了 DNS over SOCKS),请分享。
Thanks.谢谢。
As alternative on WSL(2) you can run a regular SSH tunnel.作为 WSL(2) 的替代方案,您可以运行常规 SSH 隧道。
Eg:例如:
ssh -N -L 127.0.0.1:5432:some_domain_to_forward:5432 user@jumpbox_ip
and then just connect to 127.0.0.1:5432然后只需连接到 127.0.0.1:5432
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.