État de la configuration de Reaction du serveur computing réalisé le 23 février
Apparence
Pour le fichier _actions.jsonnet
local ipBan() = ['firewall-cmd', '--zone=reaction', '--add-source=<ip>'];
local ipUnban() = ['firewall-cmd', '--zone=reaction', '--remove-source=<ip>'];
local banFor(time) = {
ban: {
cmd: ipBan(),
},
unban: {
cmd: ipUnban(),
after: time,
},
};
{
banFor: banFor,
}
Pour le fichier pattern.jsonnet
{
patterns: {
ip: {
type: 'ip',
ignore: [
// localhost
'127.0.0.1', '::1',
],
ignorecidr: [
// local network
'192.168.0.0/24',
],
},
user: {
// regex: '^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$',
regex: '[a-z_][a-z0-9_-]*[$]',
},
},
}
Pour le fichier ssh.jsonnet
local actions = import '_actions.jsonnet';
{
streams: {
ssh: {
filters: {
failedlogin: {
regex: [
@'maximum authentication attempts exceeded for <user> from <ip>',
@'Failed password for <user> from <ip>',
],
retry: 10,
retryperiod: '5m',
actions: actions.banFor('30d'),
},
scan: {
regex: [
@'Invalid user <user> from <ip>',
],
retry: 3,
retryperiod: '6h',
actions: actions.banFor('30d'),
},
},
},
},
}
Pour le fichier steams.jsonnet
local journalctl(service) = ['journalctl', '-fn0', '-u', service];
{
streams: {
ssh: {
// not sshd as sshd is an alias for ssh here (see https://github.com/systemd/systemd/issues/11846)
cmd: journalctl('ssh'),
},
},
}
Pour le fichier setup.jsonnet
{
start: [
['firewall-cmd', '--permanent', '--new-zone=reaction'],
['firewall-cmd', '--permanent', '--set-target=DROP', '--zone=reaction'],
['firewall-cmd', '--reload'],
],
stop: [
['firewall-cmd', '--permanent', '--delete-zone=reaction'],
['firewall-cmd', '--reload'],
],
}