开发者社区> 问答> 正文

Elasticsearch+x-pack认证,修改默认口令时报错?报错

修改elastic用户口令时,报错,执行的命令和报错如下:

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

Enter host password for user 'elastic': changeme

{"error":{"root_cause":[{"type":"security_exception","reason":"failed to authenticate user [elastic]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"failed to authenticate user [elastic]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

上面的错误估计很多人遇到吧,大家都怎么解决的呢?

展开
收起
爱吃鱼的程序员 2020-06-08 11:31:03 820 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    digest鉴权了。。摘要加密Basic,需要先通过认证才能进行操作

    python代码:

    importrequests
    fromrequests.authimportAuthBase
    fromrequests.authimportHTTPBasicAuth

    auth=HTTPBasicAuth('elastic','changeme')
    r=requests.get(url="http://ip:9200",auth=auth)
    print(r.text)

    这里的get改成put,带上你的参数。就可以了应该。。
     

    2020-06-08 11:31:23
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云Elasticsearch体系架构与特性解析 立即下载
开源与云:Elasticsearch应用剖析 立即下载
《Elasticsearch全观测解决方案》 立即下载