# Using "Machines"

**URL:** <https://discourse.crowdsec.net/t/using-machines/128>\
**Category:** crowdsec\
**Created:** [March 3, 2021, 9:12am UTC](https://discourse.crowdsec.net/t/using-machines/128 "2021-03-03T09:12:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![blues](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@blues](https://discourse.crowdsec.net/u/blues)\
**Post date:** [March 3, 2021, 9:12am UTC](https://discourse.crowdsec.net/t/using-machines/128/1 "2021-03-03T09:12:40Z")

</div>

I’m playing around with Crowdsec and installed the dashboard. But I’m curious about the MACHINES option in there. Is there a way to use a single dashboard to connect and monitor to multiple servers (“Machines”)? I couldn’t find any clear guidelines on how to use this.

Thanks so much in advance for any guidance.

---

<div class="post-metadata">

**Author:** ![thibault](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/thibault/32/2_2.png) [@thibault](https://discourse.crowdsec.net/u/thibault)\
**Post date:** [March 3, 2021, 11:04am UTC](https://discourse.crowdsec.net/t/using-machines/128/2 "2021-03-03T11:04:58Z")

</div>

Hello @blues !

While for users that want a simple fail2ban replacement, crowdsec might appear as a standalone software, it can actually be broken down into several components, where the “agents” (machines in your case) can run here & there, while reporting their alerts to a central component (local API) that is then used by cscli and bouncers to consume & view alerts.

You can thus connect several machines to the same local api, as it might appear in this schema :

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/crowdsec/original/1X/14690ae98e768df64f9eb818a13fa5d468f1b31b.png)

Please check if this piece of documentation answer your questions : [https://doc.crowdsec.net/Crowdsec/v1/localAPI/#machines](https://doc.crowdsec.net/Crowdsec/v1/localAPI/#machines)

And let me know 🙂

---

<div class="post-metadata">

**Author:** ![blues](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@blues](https://discourse.crowdsec.net/u/blues)\
**Post date:** [March 4, 2021, 3:43am UTC](https://discourse.crowdsec.net/t/using-machines/128/3 "2021-03-04T03:43:16Z")

</div>

Hi:

Thanks. Unfortunately the data in the documentation for the link you provided is very obtuse. Maybe if I provide a simple scenario someone can help me figure out how to make it happen?

**Machine #1 with IP 123.456.789.001**  
This machine is where I install the full CROWDSEC stack including the dashboard. For the purposes of this scenario lets assume that its handling NGINX logs.

**Machine #2 with IP 123.456.789.002**  
This machine is where I install the full CROWDSEC stack without the dashboard. For the purposes of this scenario lets assume that its also handling NGINX logs.

How do I get Machine #2 to connect to Machine #1 and push its data there so that I can monitor Machine #2 from machine #1’s dashboard?

Unfortunately, reading the documentation under “machines” does not make it clear at all how to do something like this. Maybe I’m just not smart enough to read abstracted ideas and implement them in the real world. (Or maybe I need to get Machine #1’s dashboard to connect to machine #2 instead and pull the data? It’s not clear whether one machine should be pulling or pushing data. The image above uses the term “push” so I assume "pushing from machine #2 to #1 is the correct paradigm…)

Thanks very much for any additional help this group can provide!

---

<div class="post-metadata">

**Author:** ![thibault](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/thibault/32/2_2.png) [@thibault](https://discourse.crowdsec.net/u/thibault)\
**Post date:** [March 4, 2021, 8:33am UTC](https://discourse.crowdsec.net/t/using-machines/128/4 "2021-03-04T08:33:25Z")

</div>

Hello !

Sure, let’s take this occasion to further improve the documentation, it is indeed still quite obtuse 🙂

We’re going to make **machine #1** the “master” (with the dashboard etc.) : It has crowdsec, the local API and the dashboard, and **machine #2** will simply be a slave to it, pushing its alerts there :

- make sure **machine #1** API can be reached from **machine #2**
- generate a new machine account on **machine #1** that can be used on **machine #2**
- configure **machine #2** so that it pushes its alerts to **machine #1**

Assuming you have crowdsec already install on both machines, we are going to make sure that **machine #2** pushes its alerts to **machine #1** instead of dealing with them locally (so your assumption was right) :

1. on **machine #1** , let’s edit `/etc/crowdsec/config.yaml` to make sure that the API can be reached from **machine #2**. You’re going to find the api → server section to edit the listen address :

```bash
api:
...
  server:
    log_level: info
    listen_uri: 0.0.0.0:8080

```

_note: with this change, once you restart crowdsec, the API should be accessible from other machines. Ensure that you can `telnet 123.456.789.001 8080` from **machine #2** before moving further_

1. on **machine #1** , let’s create a new machine credentials :

```bash
$ sudo cscli machines add machine_2 -a -f machine_2
$ cat ./machine_2
url: http://127.0.0.1:8080/
login: machine_2
password: xxxx

```

_note: what matters here is the login and the password, we’re going to use them later_

1. on **machine #2** , we’re going to configure crowdsec so that it pushes alerts to **machine #1**. This time, we’re going to first of all edit `/etc/crowdsec/local_api_credentials.yaml` (you can see this file referenced in the `/etc/crowdsec/config.yaml` file, api → client section). It is the file that tells crowdsec to which API endpoint (and with which credentials) it should speak to.

```bash
url: http://123.456.789.001:8080/
login: machine_2
password: xxxx

```

_note: I replace the url with the example IP of **machine #1** , use the real ip here._

Once this is done, if you trigger an attack on **machine #2** , you should see it in `cscli decisions list` and the dashboard on **machine #1**. If you’re using `cscli` from **machine #2** , it should as well speak directly to **machine #1**

Please let me know. Once it’s good, I’ll update the documentation with this 🙂

---

<div class="post-metadata">

**Author:** ![blues](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@blues](https://discourse.crowdsec.net/u/blues)\
**Post date:** [March 6, 2021, 3:58pm UTC](https://discourse.crowdsec.net/t/using-machines/128/5 "2021-03-06T15:58:38Z")

</div>

Hi - Thanks. I’ll run with this and give you feedback on how it worked.

---

<div class="post-metadata">

**Author:** ![blues](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@blues](https://discourse.crowdsec.net/u/blues)\
**Post date:** [March 9, 2021, 5:32pm UTC](https://discourse.crowdsec.net/t/using-machines/128/6 "2021-03-09T17:32:22Z")

</div>

Hi:

It looks like we were able to connect the machines. However, in viewing the data in the dashboard, a lot of the lists don’t show a “machine” column so we’re not sure exactly which machine is triggering each item in a list. Is is possible to add a “machine” column to the raw data lists (eg: descisions, alerts, events etc?

---

<div class="post-metadata">

**Author:** ![alteredCoder](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/alteredcoder/32/44_2.png) [@alteredCoder](https://discourse.crowdsec.net/u/alteredCoder)\
**Post date:** [March 11, 2021, 10:38am UTC](https://discourse.crowdsec.net/t/using-machines/128/7 "2021-03-11T10:38:33Z")

</div>

Hello, @blues

Indeed this column is missing, we are going to add it.  
We come back to you when you will can reinstall your dashboard.

---

<div class="post-metadata">

**Author:** ![shaundma](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/shaundma/32/96_2.png) [@shaundma](https://discourse.crowdsec.net/u/shaundma)\
**Post date:** [March 26, 2021, 12:04am UTC](https://discourse.crowdsec.net/t/using-machines/128/8 "2021-03-26T00:04:51Z")

</div>

Thank you ,that worked for me, after hours of searching…

---

<div class="post-metadata">

**Author:** ![tranbert](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/tranbert/32/74_2.png) [@tranbert](https://discourse.crowdsec.net/u/tranbert)\
**Post date:** [May 5, 2021, 2:07pm UTC](https://discourse.crowdsec.net/t/using-machines/128/9 "2021-05-05T14:07:46Z")

</div>

> [@thibault](#):
>
> /etc/crowdsec/config.yaml

Ok for

`listen_uri: 0.0.0.0:8080`

next I dit it via :

on machine 2 “client”

`cscli lapi register --machine machine2 -u Ip_Machine1:8080`

On machine 1 “server”

`cscli machines validate machine2`

No pass or edit to do on /etc/crowdsec/local\_api\_credentials.yaml

Is it “legit” ??? Did I miss something ?

---

<div class="post-metadata">

**Author:** ![thibault](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/thibault/32/2_2.png) [@thibault](https://discourse.crowdsec.net/u/thibault)\
**Post date:** [May 6, 2021, 6:21am UTC](https://discourse.crowdsec.net/t/using-machines/128/10 "2021-05-06T06:21:00Z")

</div>

Hello @tranbert ,

Yes it’s legit 😅 :

- `cscli lapi register --machine machine2 -u Ip_Machine1:8080` : on “client” machine, this will write to `/etc/crowdsec/local_api_credentials.yaml`, instructing crowdsec to speak to `Ip_Machine1` to push its alerts
- `cscli machines validate machine2` will actually allow “client” to speak to the server

And on this note, we’ve published a blogpost about this topic that I hope will help :

> **[How to set up a CrowdSec multi-server installation](https://crowdsec.net/2021/05/04/multi-server-setup/)**
>
> In this article we will describe how to deploy CrowdSec in a multi-server setup with one server sharing signal.

---

<div class="post-metadata">

**Author:** ![tranbert](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/tranbert/32/74_2.png) [@tranbert](https://discourse.crowdsec.net/u/tranbert)\
**Post date:** [May 6, 2021, 6:35am UTC](https://discourse.crowdsec.net/t/using-machines/128/11 "2021-05-06T06:35:21Z")

</div>

Thanks…

Seen that blogpost yesterday… after posting ! 😋

---

<div class="post-metadata">

**Author:** ![thibault](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/thibault/32/2_2.png) [@thibault](https://discourse.crowdsec.net/u/thibault)\
**Post date:** [May 6, 2021, 6:39am UTC](https://discourse.crowdsec.net/t/using-machines/128/12 "2021-05-06T06:39:58Z")

</div>

> [@tranbert](#):
>
> Seen that blogpost yesterday… after posting ! 😋

ahah sorry, better late than never 😬
