简体   繁体   English

如何在 Windows WSL2 上使用 sshuttle

[英]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.

相关问题 Kubernetes 如何在 wsl2 支持的环境中正确安装 windows 路径 - Kubernetes how to correctly mount windows path in wsl2 backed environment 如何在 Windows 10 上关闭 ssh 后保持 WSL2 运行? - How to keep WSL2 running after closing ssh on Windows 10? 如何使wsl2在Windows 10上从停止状态变为运行状态 - How to make wsl2 from stopped to running on Windows 10 将 WSL2 命令添加到 Windows Powershell - Adding WSL2 commands to Windows Powershell Windows 主机 Docker + WSL2 - 如何将 Windows 目录挂载到 ZEDC9F0A5A5D57797BF68E373674 容器 - Windows Host Docker + WSL2 - How to mount Windows directory to a Linux container 我可以使用 WSL2 进行全栈开发吗? - can I use WSL2 for fullstack development? 无法再从 Windows 资源管理器访问 WSL2 文件或从 WSL2 启动 Windows 程序 - Can no longer access WSL2 files from Windows explorer or launch Windows programs from WSL2 如何使用 127.0.0.1 从 Windows 主机访问在 WSL2 中运行的服务? - How to access service running in WSL2 from Windows host using 127.0.0.1? 来自 windows 的 http://localhost:4200 正在与来自 WSL2 的 ng serve 一起工作,这是怎么回事? - http://localhost:4200 from windows is working with ng serve from WSL2, how come? In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver? - In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM