# Username and password-based enrollment - "environment variable VAR\_NAME does not exist"

**URL:** <https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 21, 2020, 8:40am UTC](https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879 "2020-08-21T08:40:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gohovd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gohovd/32/74290_2.png) [@gohovd](https://discuss.elastic.co/u/gohovd)\
**Post date:** [August 21, 2020, 8:40am UTC](https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879/1 "2020-08-21T08:40:36Z")

</div>

I am working on an automated deployment of filebeat, and one of the steps is to enroll the beat.

As per the [documentation](https://www.elastic.co/guide/en/beats/filebeat/current/enroll-beats.html#username-password-enrollment), to have this process scripted, I need to use 'Username and password-based enrollment', where the chosen method is env:VAR.

I am on CentOS 7, and these are the steps I take:

1. export beats\_pass=some\_password
2. sudo filebeat enroll KIBANA\_URL --username USER --password env:beats\_pass

The result is:  
"environment variable beats\_pass does not exist"

Doing export -p confirms the environment variable is registered.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![gohovd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gohovd/32/74290_2.png) [@gohovd](https://discuss.elastic.co/u/gohovd)\
**Post date:** [August 24, 2020, 10:06am UTC](https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879/2 "2020-08-24T10:06:08Z")

</div>

**SOLVED**

With a workaround. Just set the "environment variable" as you do the sudo enroll, like so:

`sudo BEATS_PASS=some_password filebeat enroll KIBANA_URL --username USER --password env:BEATS_PASS --force`

PS: If you get 'empty\_access token' when using the --force flag, remove contents of /var/lib/filebeat/.

---

<div class="post-metadata">

**Author:** ![Mario\_Castro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_castro/32/35107_2.png) [@Mario\_Castro](https://discuss.elastic.co/u/Mario_Castro)\
**Post date:** [August 25, 2020, 10:43am UTC](https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879/3 "2020-08-25T10:43:24Z")

</div>

Thank you for posting the solution! 😃

---

<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:** [September 22, 2020, 12:43pm UTC](https://discuss.elastic.co/t/username-and-password-based-enrollment-environment-variable-var-name-does-not-exist/245879/4 "2020-09-22T12:43:25Z")

</div>

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