Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use proxy in WSL? #2122

Closed
yhvicey opened this issue May 17, 2017 · 3 comments
Closed

How to use proxy in WSL? #2122

yhvicey opened this issue May 17, 2017 · 3 comments

Comments

@yhvicey
Copy link

yhvicey commented May 17, 2017

  • Your Windows build number: Microsoft Windows [Version 10.0.16193.1001]

  • What you're doing and what's happening: Proxy didn't work in WSL

  • What's wrong / what should be happening instead: I switched my shadowsocks to global mode but it didn't work for programs running in WSL

Is there any way to make proxy settings valid in WSL environment?

@JoBrad
Copy link

JoBrad commented May 17, 2017

This may do what you want: I have configured SSH to use a host as a socks5 proxy. My SSH config looks something like this (h/t http://undeadly.org/cgi?action=article&sid=20070925181947):

Host tunnelhost # An alias for this host
    HostName tunnelhost.dns.entry # I'm using IP, but the DNS entry might work for you
    IdentityFile path/to/rsa/key # My id_rsa file
    User my.user.name # My username, for the tunneling host

Host myserver.env # Alias for the host I actually want to connect to. Note the extension
    HostName server.dns.entry

Host *.env # This wildcard matches the extension above
    User my.user.name 
    IdentityFile path/to/rsa/key
    PreferredAuthentications publickey,password # This tells SSH to use my public key for authing to the tunnelling host. You'll need to copy your keys to that host for this to work.
    ProxyCommand ssh -q tunnelhost nc %h %p # Tells SSH to use the tunnelhost to connect to all *.env hosts

@ZeppLu
Copy link

ZeppLu commented May 17, 2017

This alias has been in my bashrc for quite a long time:

alias socks='ALL_PROXY=socks5://127.0.0.1:1080/ \
        http_proxy=http://127.0.0.1:1080/ \
        https_proxy=http://127.0.0.1:1080/ \
        HTTP_PROXY=http://127.0.0.1:1080/ \
        HTTPS_PROXY=http://127.0.0.1:1080/'

ALL_PROXY is to be used when cloning something with git protocol, the others are all common environment variable. So commands like socks git clone, socks curl, socks wget just work. You can also directly set these variables in bashrc if you like.

@yhvicey
Copy link
Author

yhvicey commented May 18, 2017

@JoBrad I'm not using proxy with ssh but still thanks for your help.
@ZeppLu It works! thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants