Skip to content

Instantly share code, notes, and snippets.

@erronjason
Created March 19, 2014 21:21
Show Gist options
  • Save erronjason/9651634 to your computer and use it in GitHub Desktop.
Save erronjason/9651634 to your computer and use it in GitHub Desktop.
#!/bin/bash
number=$((RANDOM%30000+15000))
echo "New SSH port is "$number
if [[ -d "/etc/csf" ]];then
in_good="TCP_IN = \"20,21,"
good1=$in_good$number
eval "sed -i 's/TCP_IN = \"20,21,22,/$good1,/g' csf.conf"
out_good="TCP_OUT = \"20,21,"
good2=$out_good$number
eval "sed -i 's/TCP_OUT = \"20,21,22,/$good2,/g' csf.conf"
echo "Port opened in CSF"
else
echo "CSF not detected"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment