# Storing username and password somewhere and somehow

**URL:** <https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220>\
**Category:** Logstash\
**Created:** [July 30, 2018, 4:17pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220 "2018-07-30T16:17:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas.alvarez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas.alvarez/32/33649_2.png) [@lucas.alvarez](https://discuss.elastic.co/u/lucas.alvarez)\
**Post date:** [July 30, 2018, 4:17pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/1 "2018-07-30T16:17:28Z")

</div>

Hello everybody!. I would like to know how/where I can store credentials like username and password to be consumed from the **output.conf** file.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 30, 2018, 5:11pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/2 "2018-07-30T17:11:12Z")

</div>

If you are on a current version you could use the [keystore](https://www.elastic.co/guide/en/logstash/current/keystore.html).

---

<div class="post-metadata">

**Author:** ![lucas.alvarez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas.alvarez/32/33649_2.png) [@lucas.alvarez](https://discuss.elastic.co/u/lucas.alvarez)\
**Post date:** [July 30, 2018, 7:43pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/3 "2018-07-30T19:43:54Z")

</div>

Can this process be automated? Suppose I have 2 nodes with Logstash installed.

What I read in the documents is that you need to manually create the keystore and then set each one of the keys that you need with the corresponding values.  
I was looking for something similar, but maybe storing those global variables in a file and then referencing that file from the different config files.

Is that possible?

Thanks in advance!.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 1, 2018, 8:48pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/4 "2018-08-01T20:48:39Z")

</div>

> I was looking for something similar, but maybe storing those global variables in a file and then referencing that file from the different config files.

From an automation perspective I don't think that's materially different from creating a keystore file and referencing it from both Logstash instances.

---

<div class="post-metadata">

**Author:** ![lucas.alvarez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas.alvarez/32/33649_2.png) [@lucas.alvarez](https://discuss.elastic.co/u/lucas.alvarez)\
**Post date:** [August 2, 2018, 3:02pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/5 "2018-08-02T15:02:23Z")

</div>

And how would you create a keystore file and then reference it in the a 201-output.conf file like this one:

```
output {
    if "_grokparsefailure" in [tags] {
        elasticsearch {
            hosts => "..."
            ssl => true
            user => "..."
            password => "..."
            index => "failure_logs"
        }
    }
   ....
}

```

Sorry about the questions, but I'm struggling to find how to do this.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 2, 2018, 6:35pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/6 "2018-08-02T18:35:53Z")

</div>

I don't understand. The documentation page that was linked to earlier ([https://www.elastic.co/guide/en/logstash/current/keystore.html](https://www.elastic.co/guide/en/logstash/current/keystore.html)) has quite explicit examples and instructions that should be directly applicable in your case.

As for automation, it's trivial to create a keystore from a script but slightly less obvious how to non-interactively add a secret to the keystore. You can simply pipe the secret to the logstash-keystore program (`echo the-secret-string | logstash-keystore add name-of-secret`).

---

<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:** [August 30, 2018, 6:35pm UTC](https://discuss.elastic.co/t/storing-username-and-password-somewhere-and-somehow/142220/7 "2018-08-30T18:35:58Z")

</div>

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