# Connecting to logstash with Basic Authentication

**URL:** <https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121>\
**Category:** Logstash\
**Created:** [March 12, 2021, 7:23pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121 "2021-03-12T19:23:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alicango](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alicango/32/84498_2.png) [@alicango](https://discuss.elastic.co/u/alicango)\
**Post date:** [March 12, 2021, 7:23pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121/1 "2021-03-12T19:23:15Z")

</div>

Hello,  
I am using HTTP input plugin in logstash config. I have been always sending data to logstash over HTTP POST method by using logstash API like this;

`curl -XPOST http://<logstashIP>:9605 -d '{"my": "data"}'`

also my config like this;

```
input {
  http {
    port => 9605
    codec => "json"
  }
}
filter {
  json {
     source => "messages"
  }
}
output {
  stdout { codec => rubydebug }
}

```

But is there a way to send data to logstash with basic authentication like this;  
`curl -XPOST -u 'user:password' http://<logstashIP>:9605 -d '{"my": "data"}'`

The purpose is to send data to logstash securely.

Many thanks

---

<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:** [March 12, 2021, 7:33pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121/2 "2021-03-12T19:33:44Z")

</div>

> [@alicango](#):
>
> is there a way to send data to logstash with basic authentication

Yes. The [documentation](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html#_security) covers that.

---

<div class="post-metadata">

**Author:** ![alicango](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alicango/32/84498_2.png) [@alicango](https://discuss.elastic.co/u/alicango)\
**Post date:** [March 12, 2021, 8:01pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121/3 "2021-03-12T20:01:11Z")

</div>

Thanks @Badger now i can send data with basic auth. But logstash returns error when i use keystore for password.  
I have added the LS\_PWD for password;

```auto
/usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash list
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Warning: Nashorn engine is planned to be removed from a future JDK release
Warning: Nashorn engine is planned to be removed from a future JDK release
Warning: Nashorn engine is planned to be removed from a future JDK release
2021-03-12 19:54:18,516 main ERROR Unable to locate appender "${sys:ls.log.format}_console" for logger config "root"
2021-03-12 19:54:18,518 main ERROR Unable to locate appender "${sys:ls.log.format}_rolling" for logger config "root"
2021-03-12 19:54:18,519 main ERROR Unable to locate appender "${sys:ls.log.format}_rolling_slowlog" for logger config "slowlog"
2021-03-12 19:54:18,519 main ERROR Unable to locate appender "${sys:ls.log.format}_console_slowlog" for logger config "slowlog"
ERROR: Failed to load settings file from "path.settings". Aborting... path.setting=/etc/logstash, exception=NameError, message=>uninitialized constant LogStash::Util::Password

es_pwd
es_usr
ls_pwd

```

Then i passed in input section;

```
input {
  http {
    user => "alican"
    password => "${LS_PWD}"
    port => 9605
    type => "north"
    codec => "json"
  }
}

```

ERROR;

```auto
[ERROR] 2021-03-12 19:53:54.570 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"Java::JavaLang::IllegalStateException", :message=>"Unable to configure plugins: Cannot evaluate `${ls_pwd}`. Replacement variable `ls_pwd` is not defined in a Logstash secret store or an environment entry and there is no default value given."

```

---

<div class="post-metadata">

**Author:** ![alicango](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alicango/32/84498_2.png) [@alicango](https://discuss.elastic.co/u/alicango)\
**Post date:** [March 12, 2021, 8:28pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121/4 "2021-03-12T20:28:01Z")

</div>

I think the input section does not support **secret store** but its works with environment variable `export LS_PWD="mypassword"`

---

<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:** [April 9, 2021, 8:28pm UTC](https://discuss.elastic.co/t/connecting-to-logstash-with-basic-authentication/267121/5 "2021-04-09T20:28:20Z")

</div>

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