1,检查sshd端口误封,如果误封就重新添加。
2,代码如下:
#!/bin/bash
##written by lin
##check port 22
iptables -P INPUT ACCEPT;
iptables -P OUTPUT ACCEPT;
a=`iptables -nvL |grep dpt:22|awk '{print $3}'`
#if [ $a == "REJECT" ]||[ $a == "DROP" ]
if [ $a != "ACCEPT" ]
then iptables -I INPUT -p tcp --dport 22 -j ACCEPT
fi
3.提示错误
4,不是可以指定变量等于某个字符串吗?
5,如果有更好的建议,请附上您的脚本,感谢。
`
It seems that the comparison of unequal is using
-ne
而不是!=
~Your error is because the
a
variable is emptyYou can use the following script to check