This is what the fleet-server-log says:
Elastic Agent successfully enrolled | log.level=info @timestamp=2023-12-07T10:18:13.644Z component={"binary":"fleet-server","dataset":"elastic_agent.fleet_server","id":"fleet-server-default","type":"fleet-server"} log={"source":"fleet-server-default"} ecs.version=1.6.0 service.name=fleet-server event.duration=540159862 http.request.id=01HH1WHXQCAY85NB8E1BMAS683 mod=enroll fleet.access.apikey.id=cLjIQ4wBDhRRmoi29_ft server.address= fleet.agent.id=c9c43654-d4e6-4871-af6f-c006f798e0d2 fleet.enroll.apikey.id=rPCpPowBvVJYkqdV31Qh fleet.policy.id=decf4020-9421-11ee-aeef-d51c0661d7e8 http.response.body.bytes=1874
ApiKey fail authentication | log.level=info @timestamp=2023-12-07T10:18:38.799Z component={"binary":"fleet-server","dataset":"elastic_agent.fleet_server","id":"fleet-server-default","type":"fleet-server"} log={"source":"fleet-server-default"} http.request.id=01HH1WJPRTF4XH5K1YHGGWJEB5 server.address= fleet.apikey.id=Fh8dP4wBRaQ9-NH2Omcu service.name=fleet-server event.duration=35355116 ecs.version=1.6.0 error.message=apikey auth response Fh8dP4wBRaQ9-NH2Omcu: [401 Unauthorized] {"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}},"status":401}
HTTP request error | log.level=info @timestamp=2023-12-07T10:18:38.799Z component={"binary":"fleet-server","dataset":"elastic_agent.fleet_server","id":"fleet-server-default","type":"fleet-server"} log={"source":"fleet-server-default"} ecs.version=1.6.0 http.request.id=01HH1WJPRTF4XH5K1YHGGWJEB5 server.address= http.response.status_code=400 service.name=fleet-server error.message=apikey auth response Fh8dP4wBRaQ9-NH2Omcu: [401 Unauthorized] {"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}},"status":401} event.duration=35432654
And this is what happens on Windows:
PS C:\temp\elastic-agent-8.8.2-windows-x86_64> .\elastic-agent.exe enroll --url=https://<fleet-server>:8220 --enrollment-token=clBDcFBvd0J2VkpZa3FkVjMxUWg6TzdqOURabWtSVldfYUdxY0dPcktHQQ==
This will replace your current settings. Do you want to continue? [Y/n]:
{"log.level":"info","@timestamp":"2023-12-07T11:18:12.766+0100","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":478},"message":"Starting enrollment to URL: https://<fleet-server>:8220/","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-12-07T11:18:13.908+0100","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":274},"message":"Elastic Agent might not be running; unable to trigger restart","ecs.version":"1.6.0"}
Successfully enrolled the Elastic Agent.
PS C:\temp\elastic-agent-8.8.2-windows-x86_64> & 'C:\Program Files\Elastic\Agent\elastic-agent.exe' status
State: STARTING
Message: Waiting for initial configuration and composable variables
Fleet State: FAILED
Fleet Message: status code: 400, fleet-server returned an error: BadRequest, message: apikey auth response Fh8dP4wBRaQ9-NH2Omcu: [401 Unauthorized] {"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"unable to authenticate with provided credentials and anonymous access is not allowed for this request","additional_unsuccessful_credentials":"API key: api key [Fh8dP4wBRaQ9-NH2Omcu] has been invalidated","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}},"status":401}
Components: (none)