0

what I'm trying to do is modify my action.d/iptables-allports.conf:

actionban = ssh fail2ban@saltmaster.net 'salt '*' iptables.insert position=1 rule='-s <ip> -j DROP -m comment --comment "<server> | <name> | hits: <failures> | time: <time>"'

On my fail2ban actionban, I want it to ssh to the saltmaster and issue the above command so that it sends the iptables drop to every minion.

The command works perfectly fine without salt, when I just ssh to a single server.

The problem here is I don't know how to nest the single quote ' correctly when I add salt '*' without breaking the command above.

Can someone advise how to do it properly?

1 Answers1

0

Try this

actionban = ssh fail2ban@saltmaster.net 'salt \'*\' iptables.insert position=1 rule=\'-s <ip> -j DROP -m comment --comment "<server> | <name> | hits: <failures> | time: <time>"'

You can always add a \' to escape inner quotes.

Mike
  • 21,910
  • 7
  • 55
  • 79