# Unable to log in elastic using the non-default user's username and password

**URL:** https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937
**Category:** Elastic Cloud on Kubernetes (ECK)
**Created:** [January 29, 2020, 3:15am UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937 "2020-01-29T03:15:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pingz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pingz/32/58555_2.png) [@pingz](https://discuss.elastic.co/u/pingz)
#### Post date: [January 29, 2020, 3:15am UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937/1 "2020-01-29T03:15:24Z")

</div>

I was able to successfully create a user 'test1' and assign it the superuser role.  
Execute rest api  
POST /\_security/user/test1?pretty  
{  
"password" : "test@1",  
"roles" : ["superuser"],  
"full\_name" : "Test User",  
"email" : "[testuser@example.com](mailto:testuser@example.com)",  
"metadata" : {  
"intelligence" : 7  
}  
}

The user is successfully created  
{  
"created" : true  
}

But when I tried to invoke elastic api using the newly created user 'test1', I got the following error

curl -u test1:test@1 [https://es.endpoint](https://es.endpoint)  
{"error":{"root\_cause":[{"type":"security\_exception","reason":"unable to authenticate user [test1] for REST request [/]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}}],"type":"security\_exception","reason":"unable to authenticate user [test1] for REST request [/]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}},"status":401}

My elastic stack was set up using the following configuration. The default elastic user works fine. Any idea why test1 does not work?

apiVersion: [elasticsearch.k8s.elastic.co/v1](http://elasticsearch.k8s.elastic.co/v1)  
kind: Elasticsearch  
metadata:  
name: quickstart  
namespace: log-server  
spec:  
version: 7.5.1  
http:  
tls:  
selfSignedCertificate:  
disabled: true  
nodeSets:

- name: default  
count: 3  
config:  
xpack.security.authc:  
anonymous:  
username: anonymous  
roles: superuser  
authz\_exception: false

---

<div class="post-metadata">

### Author: ![pingz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pingz/32/58555_2.png) [@pingz](https://discuss.elastic.co/u/pingz)
#### Post date: [January 29, 2020, 7:08pm UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937/2 "2020-01-29T19:08:43Z")

</div>

Figured out myself. This is due to the license. With basic license, I must explicitly set xpack.security.enabled: true

---

<div class="post-metadata">

### Author: ![sebgl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebgl/32/48702_2.png) [@sebgl](https://discuss.elastic.co/u/sebgl)
#### Post date: [January 30, 2020, 8:56am UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937/3 "2020-01-30T08:56:28Z")

</div>

`xpack.security.enabled: true ` is supposed to be set by ECK, by default.  
Are you saying it works when you set it yourself, but does not work when you don't set it?

---

<div class="post-metadata">

### Author: ![pingz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pingz/32/58555_2.png) [@pingz](https://discuss.elastic.co/u/pingz)
#### Post date: [January 30, 2020, 10:27pm UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937/4 "2020-01-30T22:27:06Z")

</div>

Somehow it is not set and I have to explicitly set to true. If I don't specify xpack.security.enabled, it does not work  
Not clear if this has anything to do with the other xpack features in my nodeSet configuration as I set other features explicitly, such as xpack.monitoring.enabled.

I know that if nodeSet configure only has following. xpack.security.enabled seems to be set to true as default

```
  node.master: true
  node.data: true
  node.ingest: true
  node.store.allow_mmap: false
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 4, 2022, 7:42am UTC](https://discuss.elastic.co/t/unable-to-log-in-elastic-using-the-non-default-users-username-and-password/216937/5 "2022-11-04T07:42:34Z")

</div>


