Jump to content

Linux Script

Go to solution Solved by C2dan88,

So you want to shorten  "fail2ban-client set web-manual-jail banip x.x.x.x"  to just mb x.x.x.x

 

Easiest way is to use an alias in your .bashrc file

alias mb='fail2ban-client set web-manual-jail banip'

Now you can just use mb x.x.x.x 

Hello guys,

 

does anyone know how to create a script which would do the following: "fail2ban-client set web-manual-jail banip {x}.{x}.{x}.{x}"

I have a decent list of IPs that need to be added to that jail (web-manual-jail) and was wondering if something like this could be made? So that for example I only need to run "mb x.x.x.x" (mb - "manual ban").

 

Your help would be appreciated!

Thanks!

Link to comment
https://linustechtips.com/topic/1248057-linux-script/
Share on other sites

Link to post
Share on other sites

1 minute ago, Gomo said:

Clearly I am a bit clueless on how to do that.. would the parameter / placeholder part work?

OH, I misunderstood. I thought the "x.x.x.x" part was just an example placeholder. In that case it's still quite simple, you can use $1 to refer to the first argument given to the script when you run it.

https://www.lifewire.com/pass-arguments-to-bash-script-2200571

 

so basically you'd have

fail2ban-client set web-manual-jail banip $1

 

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
https://linustechtips.com/topic/1248057-linux-script/#findComment-14031663
Share on other sites

Link to post
Share on other sites

2 minutes ago, C2dan88 said:

So you want to shorten  "fail2ban-client set web-manual-jail banip x.x.x.x"  to just mb x.x.x.x

 

Easiest way is to use an alias in your .bashrc file


alias mb='fail2ban-client set web-manual-jail banip '

 

Thanks! that's pretty much what I was looking for :)

 

@SauronThanks as well!

Link to comment
https://linustechtips.com/topic/1248057-linux-script/#findComment-14031677
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×