crowdsec icon indicating copy to clipboard operation
crowdsec copied to clipboard

rename machine

Open celevra opened this issue 3 years ago • 11 comments

hi,

we have added all machines via

cscli lapi register -u url:port

the get a random machineID there is no "name" or something that is in link with the ID that means the machineID and IP is the only thing to identifiy the machine

if we had created a machine account before we could have namend the System

is there a way to rename it? or do we have the rejoin all machines?

regards

celevra avatar Jun 30 '21 18:06 celevra

Hello @celevra,

When you run cscli lapi register you can give a name to your crowdsec agent with --name flag like:

cscli lapi register -u url:port --name myMachine

is there a way to rename it? or do we have the rejoin all machines?

Currently, it is not possible to rename a machine already registered to the LAPI :disappointed:

AlteredCoder avatar Sep 09 '21 16:09 AlteredCoder

@AlteredCoder which version is the --name option available in please? It doesn't appear in mine (version below). The --machine flag doesn't have the desired effect either.

Register you machine to the Local API (LAPI).
Keep in mind the machine needs to be validated by an administrator on LAPI side to be effective.

Usage:
  cscli lapi register [flags]

Flags:
  -f, --file string      output file destination
  -h, --help             help for register
      --machine string   Name of the machine to register with
  -u, --url string       URL of the API (ie. http://127.0.0.1)

Global Flags:
  -c, --config string   path to crowdsec config file (default "/etc/crowdsec/config.yaml")
      --debug           Set logging to debug.
      --error           Set logging to error.
      --info            Set logging to info.
  -o, --output string   Output format : human, json, raw.
      --trace           Set logging to trace.
      --warning         Set logging to warning.
2021/12/28 17:01:03 version: v1.2.1-debian-pragmatic-dd03d073558e380c283afe66942f537c3da647ff
2021/12/28 17:01:03 Codename: alphaga
2021/12/28 17:01:03 BuildDate: 2021-11-18_10:12:30
2021/12/28 17:01:03 GoVersion: 1.16.7
2021/12/28 17:01:03 Constraint_parser: >= 1.0, <= 2.0
2021/12/28 17:01:03 Constraint_scenario: >= 1.0, < 3.0
2021/12/28 17:01:03 Constraint_api: v1
2021/12/28 17:01:03 Constraint_acquis: >= 1.0, < 2.0

nameduser0 avatar Dec 28 '21 17:12 nameduser0

The --machine flag worked for me today on FreeBSD.

2022/06/09 01:24:57 version: v1.3.4-c196ed45b62c12d9c6549da927c37c64bd08c642
2022/06/09 01:24:57 Codename: alphaga
2022/06/09 01:24:57 BuildDate: 2022-05-24_04:09:55
2022/06/09 01:24:57 GoVersion: 1.18.2
2022/06/09 01:24:57 Platform: freebsd
2022/06/09 01:24:57 Constraint_parser: >= 1.0, <= 2.0
2022/06/09 01:24:57 Constraint_scenario: >= 1.0, < 3.0
2022/06/09 01:24:57 Constraint_api: v1
2022/06/09 01:24:57 Constraint_acquis: >= 1.0, < 2.0

For anyone else arriving here: https://docs.crowdsec.net/docs/user_guides/machines_mgmt/#machine-register

brettinternet avatar Jun 09 '22 07:06 brettinternet

HI, is renaming still not possible? I am using Docker compose and the machine is named 'localhost'. When I receive email and slack notifications it would be nice to see which host they came from. Any workaround for this?

vitobotta avatar Jan 17 '23 09:01 vitobotta

HI, is renaming still not possible? I am using Docker compose and the machine is named 'localhost'. When I receive email and slack notifications it would be nice to see which host they came from. Any workaround for this?

If you are using docker compose you can use the environment variable called CUSTOM_HOSTNAME to set the name

CUSTOM_HOSTNAME | localhost | Name for the local agent (running in the container with LAPI)

@vitobotta

LaurenceJJones avatar Jan 17 '23 09:01 LaurenceJJones

@LaurenceJJones Hi! and thanks for the quick response. What if the machine is already registered?

vitobotta avatar Jan 17 '23 09:01 vitobotta

@vitobotta Depends what you mean by already "registered". If the machine only talks to itself, on the latest version (1.4.5) it will re register itself under the new name.

LaurenceJJones avatar Jan 17 '23 09:01 LaurenceJJones

Looks like it worked! I just recreated the container with compose, it registered a machine with the custom name, then I just deleted the localhost one. Now I get notifications with the custom hostname. Thanks!

vitobotta avatar Jan 17 '23 09:01 vitobotta

An alternative is to change the name in the local_api_credentials.yaml file and in the database (machines table).

Afterwards restart crowdsec of course...

wimg avatar May 13 '23 13:05 wimg