简体   繁体   中英

How to Use sshuttle on Windows WSL2

We have a Jenkins server which is accessible only from within the VPC on the cloud. 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. Everything works fine.
Now I'm on Windows and trying to do the same on 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. The ssh connection is established and I can access my Jenkins (using curl ).
Then I tried to access my Jenkins on Windows via WSL2:
1. I found the IP address of WSL2 and the port the ssh tunnle:

# 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:

 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. I tested via Powershell that the SOCKS port is open and responding (using Test-NetConnection ).
1. Any idea what the problem is? How to make it work?
2. If it's not gonna work, is there any other solution (eg Docker, etc)?
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.
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. It seems Windows 10 has OpenSSH and you can use it. Just open CMD and type ssh -D 1080 rad@bastion and setup Firefox to use localhost as the proxy.
If there's any better solution or any comment/concern (apart from DNS over SOCKS) with this approach, please share.
Thanks.

As alternative on WSL(2) you can run a regular SSH tunnel.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM