我有一个小问题。我正在用systemd做一个服务(守护进程(。脚本如下:
if [ $intento = 5 ];then
iptables -I INPUT -s ${sublista[0]} -j DROP -m comment --comment "IP bloqueada por sshield"
date=$(date)
echo "${sublista[0]} $date" >> /var/cache/sshield.deny
zenity --notification --text "IP address ${sublista[0]} denied at $date - sshield"
email ivanherediaplanas@hotmail.com "Nueva regla iptables | ${sublista[0]} denied" "The ${sublista[0]} ip address is denied by brute force's attack ssh.<br><br>Date: $date"
declare -a ips=(${ips[@]/${sublista[0]}=>$intento/})
fi
想法如下:
如果尝试次数超过五次,它会给出ip地址并锁定它。发送邮件并显示zenity的弹出窗口
问题是,弹出窗口不会显示。
zenity——通知——文本";IP地址${sublista[0]}在$date-shield"处被拒绝
我相信这是因为,scrpt是由/lib/systemd/system/shield.service 中的服务文件执行的
[Unit]
Description=Service for protect attacks of brute force ssh's
[Service]
Type=simple
ExecStart=/etc/sshield/sshield.sh
ExecStop=/etc/sshield/sshield.sh stop
RemainAfterExit=yes
Restart=always
[Install]
WantedBy=multi-user.target
我认为问题在于:Type=simple
此外,我尝试使用这个:
echo "${sublista[0]} $date" >> /var/cache/sshield.deny
sshield --bell "IP address ${sublista[0]} denied at $date - sshield"
email ivanherediaplanas@hotmail.com "Nueva regla iptables | ${sublista[0]} denied" "The ${sublista[0]} ip address is denied by brute force's attack ssh.<br><br>Date: $date"
sshield--bell"IP地址${sublista[0]}在$date-shield"处被拒绝;
命令sshield
是路径/bin/sshield
中的一个脚本,我将遵循它:
elif [[ $argumento == "--bell" ]];then
if [[ $# -gt 3 ]];then
echo -e "