修改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}
上面的错误估计很多人遇到吧,大家都怎么解决的呢?
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,带上你的参数。就可以了应该。。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。