> For the complete documentation index, see [llms.txt](https://prime-stake-pool.gitbook.io/node-setup-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prime-stake-pool.gitbook.io/node-setup-guide/server-setup-basics/how-to-setup-your-cloud-server-securely/install-fail2ban.md).

# Install fail2ban

Fail2Ban is the security layer in which you reduce the number of attempts from the unknown ip's trying to break in to your server. This is done by setting up the following parameters in the file 'jail.conf'. That includes:

[#ignoreip](https://www.primestakepool.com/blog/hashtags/ignoreip) = 127.0.0.1/8 ::1

[#bantime](https://www.primestakepool.com/blog/hashtags/bantime) = 10m

[#findtime](https://www.primestakepool.com/blog/hashtags/findtime) = 10m

[#maxretry](https://www.primestakepool.com/blog/hashtags/maxretry) = 5m

\[sshd]

Remember to remove hash # before each parameter to take effect.

Now let's install fail2ban:

```
sudo apt install fail2ban
```

<figure><img src="/files/pRrIwCAVIk4dQRoTBzzl" alt=""><figcaption></figcaption></figure>

```
 cd /etc/fail2ban
```

```
ls
```

action.d fail2ban.conf fail2ban.d filter.d jail.conf paths-arch.conf paths-common.conf\
paths-debian.conf paths-opensuse.conf

<figure><img src="/files/3WyRy31vMIfJ4ixzI3mI" alt=""><figcaption></figcaption></figure>

Let's see the contents of the file 'jail.conf'.

<figure><img src="/files/MmJ0WgYw1GCtWhM7SJ1M" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/19qIKyjGntDh6etOwNq7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/3cTUHguNzPayfGnHdulU" alt=""><figcaption></figcaption></figure>

We need to change the parameters in the file 'jail.conf'. But if we do so, then while updating the Ubuntu system packages the file gets overwritten and restored to its default settings. For this not to happen we need to cp 'jail.conf' to 'jail.local'.

```
cp jail.conf jail.local
```

<figure><img src="/files/GP1aGaU7xJz7D4u1j6vR" alt=""><figcaption></figcaption></figure>

Now lets change the parameter in the file 'jail.local'.

```
sudo nano jail.local
```

<figure><img src="/files/zUUKOo03I9dyPTlh53gU" alt=""><figcaption></figcaption></figure>

In 'ignoreip' just put your local computer ip address with a space after '127.0.0.1/8 ::1 '.

ignoreip = 127.0.0.1/8 ::1 192.163.6.4

ignoreip = 127.0.0.1/8 ::1 192.163.6.4/24

ignoreip = 127.0.0.1/8 ::1 192.163.6.4/32

Also put '/24' after your local computer's ip address if you don't want ip's coming from your local network to get banned and put '/32' if you don't want network having single IPv4 address to get banned. For details about IPv4 CIDR blocks visit wikipedia page [here](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#:~:text=These%20groups%2C%20commonly%20called%20CIDR,%2C%20i.e.%2C%20a.b.c.d%2Fn).

<figure><img src="/files/tcpYPJZCWe7pHLdvarVR" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/P4M2wt7QGNggwIW92ayr" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/TNwO73dX7yjHSj9VFZ3u" alt=""><figcaption></figcaption></figure>

Keep bantime, findtime, maxretry to default settings i.e. [bantime](https://www.primestakepool.com/blog/hashtags/bantime) = 10m  [findtime](https://www.primestakepool.com/blog/hashtags/findtime) = 10m  [maxretry](https://www.primestakepool.com/blog/hashtags/maxretry) = 5m as it is sufficient to keep the bad actors away from re-attempting to break into your server.&#x20;

Under \[sshd]  enter line 'enable = true' and change the port to your ssh port. If it is port 22 then you can simply keep it as 'ssh'.&#x20;

<figure><img src="/files/OGAgGuu2RqPtj3fqw7vf" alt=""><figcaption></figcaption></figure>

Restart fail2ban for settings to take effect

```
sudo systemctl restart fail2ban
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://prime-stake-pool.gitbook.io/node-setup-guide/server-setup-basics/how-to-setup-your-cloud-server-securely/install-fail2ban.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
