Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a script to authenticate in hudson using wget and store the authentication cookie.

The contents of the script is this:

wget \
--no-check-certificate \
--save-cookies /home/hudson/hudson-authentication-cookie \
--output-document "-" \

Unfortunately, when I run this script, I get:

--2011-02-03 13:39:29--  https://myhudsonserver:8443/hudson/j_acegi_security_check?     j_username=my_username&j_password=my_password&remember_me=true
Resolving myhudsonserver...
Connecting to myhudsonserver||:8443... connected.
WARNING: cannot verify myhudsonserver's certificate, issued by `/C=Unknown/ST=Unknown/L=Unknown/O=Unknown/OU=Unknown/CN=myhudsonserver':
  Self-signed certificate encountered.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://myhudson:8443/hudson/;jsessionid=087BD0B52C7A711E0AD7B8BD4B47585F    [following]
--2011-02-03 13:39:29--      https://myhudsonserver:8443/hudson/;jsessionid=087BD0B52C7A711E0AD7B8BD4B47585F
Reusing existing connection to myhudsonserver:8443.
HTTP request sent, awaiting response... 404 Not Found
2011-02-03 13:39:29 ERROR 404: Not Found.

There's no error log in any of hudson's tomcat log files.

Does anyone has any idea about what might be happening?


share|improve this question

Here's the equivalent using curl:

curl --cookie-jar /home/hudson/hudson-authentication-cookie \
     --data-urlencode "j_username=my_username" \
     --data-urlencode "j_password=my_password" \
     --data-urlencode "remember_me=true" \
     --insecure https://myhudsonserver:8443/hudson/j_acegi_security_check

This should work, although depending on what you really need to do, there may be a better approach.

In particular if you just need a single query, include a "from=/hudson/..." in the form data so that the 302 redirect leads to the resource that you're actually interested in. If you add --location, curl will follow the 302 redirect and will use the cookies (--cookie-jar is still required, unfortunately). This makes a nice one-liner:

curl --cookie-jar /home/hudson/hudson-authentication-cookie \
     --data-urlencode "j_username=my_username" \
     --data-urlencode "j_password=my_password" \
     --data-urlencode "from=/hudson/view/myview/api/json" \
     --insecure --location https://myhudsonserver:8443/hudson/j_acegi_security_check
share|improve this answer
For some reason it didn't work. I end up doing the script in perl and www::mechanize. Thanks! – Rafael May 14 '11 at 0:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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