Question

Thank you for existing and making my life easier :). I need your help, please.

I need to create a putty function to work like this.

A command in putty:

ipfw addip [IP]

This will add in /etc/rules.ipfw the following line:

$IPF 460 allow all from [IP] to any 22 in

A command in putty:

ipfw removeip [IP]

This will search in /etc/rules.ipfw for the line with specific [IP] and it will remove it. Example line to be removed

$IPF 460 allow all from [IP] to any 22 in

Thank you.

Was it helpful?

Solution

It sounds like what you want is a shell script for the user to run after connecting to the server with PuTTY. ipfw_addip to do this:

#! /bin/sh
echo "\$IPF 460 allow all from $1 to any 22 in" >> /etc/ipfw.rules

and ipfw_removeip:

#! /bin/sh
grep -v "allow all from $1" /etc/ipfw.rules > /tmp/ipfw.$$
mv /tmp/ipfw.$$ /etc/ipfw.rules

Those are very simplistic examples, and in a production environment should make more sanity checks, but they may help you get started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top