LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Restrict Proftp users via "ALLOW ..." (https://www.linuxquestions.org/questions/linux-security-4/restrict-proftp-users-via-allow-4175546976/)

HardenedCriminal 07-01-2015 08:50 PM

Restrict Proftp users via "ALLOW ..."
 
I am trying to determine the IP of my dynamic Proftp users and then only allow their IP addresses access.

My problem is I can't get the first SED line to work to delete out all the old values first before putting in the new ones. Thanks to all in advance.

===========================================

#!/bin/bash
# declare an array called array and define values
array=(
someone.noip.com \
someoneelse.noip.com \
etc.noip.com \
)

for I in "${array[@]}"
do

IP=`host $I | awk '{print $4}'` # Gets the IP address of each in array

echo $IP
sed -i '/$a$I/d' /etc/proftpd.d/allowedIPusers.conf # delete out old values BUT DOESN'T WORK!
sed -i "8i Allow $a$IP #$a$I" /etc/proftpd.d/allowedIPusers.conf # insert after line 8

done
exit

HardenedCriminal 07-01-2015 08:52 PM

Not thinking...
---------------------------------------
#!/bin/bash
sed -i '/noip/d' /etc/proftpd.d/allowedIPusers.conf # delete out old values first and start clean

# declare an array called array and define values
array=(
someone.noip.com \
someoneelse.noip.com \
etc.noip.com \
)

for I in "${array[@]}"
do

IP=`host $I | awk '{print $4}'` # Gets the IP address of each in array

echo $IP
sed -i "8i Allow $a$IP #$a$I" /etc/proftpd.d/allowedIPusers.conf # insert after line 8

done
exit


All times are GMT -5. The time now is 08:07 AM.