Can't change default password


(Shlomi Toren) #1

Hey, I installed Xpack for elasticsearch, and tried to to change the password as it says here:
https://www.elastic.co/guide/en/x-pack/current/security-getting-started.html

Running this:
curl -XPUT -u elastic localhost:9200/_xpack/security/user/elastic/_password -H Content-Type: application/json -d {"password" : "elasticpassword"}

is getting me:
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('p' (code 112)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4a142671; line: 1, column: 3]"}],"type":"json_parse_exception","reason":"Unexpected character ('p' (code 112)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4a142671; line: 1, column: 3]"},"status":500}curl: (6) Could not resolve host: application
curl: (3) Bad URL, colon is first character
curl: (3) [globbing] unmatched close brace/bracket in column 16

or, running this:

curl -XPUT -u elastic "localhost:9200/_xpack/security/user/elastic/_password" -H "Content-Type: application/json -d {"password" : "elasticpassword"}

gets me this:
{"error":{"root_cause":[{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}],"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"},"status":500}

I can't seem to get it, no matter what combination of " or ' Im using. Please help!

Thanks


(Steve Kearns) #2

It looks like you're missing some quotes in the first example, and have both unclosed and missing quotes in the second one. Here's what it should look like:

curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -H "Content-Type: application/json" -d '{"password" : "elasticpassword"}'

Note the single quotes around the URL, double quotes around the content-type, and the single quotes around the text following the -d. I believe the docs you link to have this quoted correctly, but let us know if there is an issue in the docs!

Thanks,
Steve


(Shlomi Toren) #3

Hey Steve, thank you for replying.
I tried that first, of course, but got this:

Enter host password for user 'elastic':
curl: (6) Could not resolve host: 'localhost
curl: (3) Bad URL, colon is first character
curl: (3) [globbing] unmatched close brace/bracket in column 16

I assumed it was because of the single quotes.
To remove any shadow of a doubt, I'm using curl through CMD.

BTW: using 127.0.0.1 or my actual IP doesn't change the outcome.


(Shlomi Toren) #4

This worked:
curl -XPUT -u elastic localhost:9200/_xpack/security/user/elastic/_password -H "Content-Type: application/json" -d "{"password" : "elasticpassword"}"

Why do I need to escape quotes? I don't remember doing it previously.


(Steve Kearns) #5

Hi Shiomi,

Glad to hear you were able to get it to work. On my mac, the command I pasted worked just fine. Perhaps on another OS, you may be required to include http:// before localhost. but either way, glad you're up and running!

Thanks,
Steve


(Shlomi Toren) #6

Didn't help with the escape thing. Thanks anyway!


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.