Skip to content

How to use proxy in WSL? #2122

Closed
Closed

Description

@yhvicey
  • 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?

Activity

  1. JoBrad commented on May 17, 2017

    @JoBrad

    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
  2. ZeppLu commented on May 17, 2017

    @ZeppLu

    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.

  3. yhvicey commented on May 18, 2017

    @yhvicey
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions