12

I want to do a post (twitter in this case) with a oneliner.

If I don't have proxy

curl -u user:pass -d status="message" http://twitter.com/statuses/update.xml

works perfectly.

But when I am behind a authenticated proxy it doesn't.

I had tryied:

curl -X proxy:port -U proxyUser:proxyPass -u user:pass -d status="message" http://twitter.com/statuses/update.xml

That it jump me with an

proxy do not support basic auth

So do you know what I am doing wrong?

thanks in advance.

6 Answers 6

21

Cababunga's answer is correct, but they're missing another option: --proxy-ntlm. Some proxies won't authorize correctly with --proxy-anyauth, so ideally you'll want to specify the authentication method that your proxy uses. If you run curl -v -U user:pass -x proxy:port --url http://www.google.com, you should get something along the lines of the following:

  • About to connect() to proxy [your proxy] port [your port] (#0)
  • Trying [IP]...
  • connected
  • Connected to [your proxy] ([IP]) port [your port] (#0)
  • Establish HTTP proxy tunnel to www.google.com:443
  • Proxy auth using Basic with user '[user]'
  • CONNECT www.google.com:443 HTTP/1.1
  • Host: www.google.com:443
  • Proxy-Authorization: Basic [gibberish]
  • User-Agent: curl/[ver] ([OS]) libcurl/[ver] OpenSSL/[ver] zlib/[ver]
  • Proxy-Connection: Keep-Alive
  • HTTP/1.1 407 Proxy Authentication Required
  • Proxy-Authenticate: NEGOTIATE
  • Proxy-Authenticate: NTLM

Add a flag for whatever you see in the Proxy-Authenticate parameter and you should be good to go. In this example, you would add the --proxy-ntlm flag.

6

You may be able to put the username/password in the URL for the authenticated resource to avoid having extra command line complications.

http://username:[email protected]/statuses/update.xml

also, the --proxy shortcut is a lowercase x, as cababunga pointed out.

curl -x proxyaddr:port -U proxyUser:proxyPass -u user:pass -d status="message" http://twitter.com/statuses/update.xml
3

Try to add --proxy-digest or --proxy-anyauth. And I think to connect to proxy you should use lower case -x (not -X).

1

I managed to perform this with the help of the Micah's answer here:

this is the command I got at the end to access a BitBucket repo:

curl  -u userBitbucket:PwdBitBucket -U userProxy:pwdProxy -x address_proxy:port:proxy --proxy-ntlm http://host:port/projects/project/repos/repo/browse/file
1

You may want to try using SOCKS v5 instead of v4:

$ curl --proxy socks5://proxyUser:proxyPass@proxy:port ...
0

I had this issue too, It doesn't resolved by just using --proxy-ntlm, Because I am working in a company with multiple network domains, Then by adding domain on my proxy's username:password it worked well:

curl -v --proxy-ntlm -U domain/username:password --proxy http://proxy:port https://www.google.com

Or in case of using general environment variable:

export proxy=http://domain%2Fusername:password@proxy:port
export http_proxy=%proxy%
export HTTP_PROXY=%proxy%
export https_proxy=%proxy%
export HTTPS_PROXY=%proxy%
export no_proxy=127.0.0.1,localhost,172.17.0.0,172.27.0.0

In case of using Windows please replace export with set

curl --proxy-ntlm https://www.google.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.