SSH is a critical service for system administrators, but it is often targeted by brute-force attacks. As part of the Pangolin open-source project, securing your infrastructure is a priority. Beside other security measures like setting e.g. proper firewall rules, we could use crowdsec to scan our auth.log for suspicious behaviours. To additionally secure your hosts ssh access using crowdsec, we’ll have to take a couple of steps.
Install local bouncer on your host
To be able to react to crowdsec decisions (made in its docker container ;) on host-level, we need to install a remediation component. If you don’t have crowdsec repositories installed, check their documentation. We will name it “host-bouncer” in the following steps.
|
|
Add bouncer in crowdsec
Here we will take the step into our crowdsec container and create a new bouncer.
|
|
This will give you an API Key which our “host-bouncer” will use to “connect” to crowdsec.
Configure host bouncer
Now we will edit the configuration of our “host-bouncer” accordingly:
|
|
Under “api_key” add the API Key we just created. The api_url gives us an idea what to do next :)
|
|
Edit pangolin’s docker-compose.yaml
In the next step we have to edit the docker-compose.yaml to open up our containers a little bit.
Expose port 8080
As our local firewall bouncer will try to connect to the endpoint given in its crowdsec-firewall-bouncer.yaml…
|
|
… we will have to expose it in pangolin’s docker-compose.yaml
|
|
Make your auth.log available to crowdsec
And to make the host’s auth.log available in the crowdsec container… we’ll map the /var/log/ directory to the container:
|
|
Create an acquisition-file
Last but not least we create an acquisition-file in the config/crowdsec/acquis.d/ directory. If your pangolin installation in located under /opt/pangolin/…
|
|
You could put the acquisition to your acquis.yaml file as well, but this is outdated.
|
|
After restarting your stack, crowdsec should start parsing your auth.log. Check if you have proper sshd collections installed.
Your auth.log should show up in metrics after connecting to ssh
|
|
When setup correctly, our new bouncer should appear…
…as well as our auth.log acquisition…
This is another small layer to make your VPS a little bit safer.