Search code examples
bashcurlproxypasswordstor

How do I pass a blank proxy username/password using curl?


I’m using bash shell on Mac El Capitan. How do I pass a blank username/password for a proxy server using curl? I tried this

localhost:tmp davea$ curl http://www.google.com --proxy localhost:9050 --proxy-user "":""
514 Authentication required.

I’m running a tor daemon on my machine using this command

tor --CookieAuthentication 0 --HashedControlPassword "" --ControlPort 9050 --SocksPort 50001

and I’m able to connect through Telnet without entering a password like so

localhost:tmp davea$ telnet localhost 9050
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
AUTHENTICATE
250 OK

so I know that my password, at least, is correct.


Solution

  • Note that when using curl from the command line, the --proxy option is specifically for use with an HTTP proxy which Tor is not, it's a SOCKS proxy.

    To get around this, use what Nehal suggested in the comments to use a SOCKS proxy (you'll probably want to use --socks5-hostname instead so the DNS resolution is also performed over Tor as well, otherwise you leak DNS requests locally).

    So your call would look like:

    curl http://www.google.com -L --socks5-hostname localhost:50001
    

    Side note: The control port (9050) is only used for communicating commands to the controller. This port is not used to proxy requests at all.