gpg签名批量验证的2个脚本

gpg签名批量验证的2个脚本

gpq签名验证

gpg --import some_pub-key.txt 导入公钥
gpg --fingerprint 打印指纹
gpg --edit-key "some key is uid" trust  设置信任级别
gpg --verify file-name.asc 验证签名。

根据asc验证文件的批量验证脚本,只检查当前目录

[root@FTPServer1 software]# cat gpg.sh
#!/bin/bash
ls *.asc | awk '{ print "gpg --verify ",$1 }' > gpgall.sh
if [ $? -ne 0 ]; then
  echo "Can't write file!"
  exit 1
fi
sh ./gpgall.sh  > gpgall.log 2>&1
echo "gpg verify is done. Please check gpgall.log, and make sure every file is Good signature!"
num_asc=`ls *.asc| wc -l`
num_good_sign=`grep "Good signature" gpgall.log | wc -l`
echo "Total asc file is: ${num_asc}."
echo "Total Good signature is: ${num_good_sign}."
echo -n "You can press y to check the File: "
read result
if [ $result == "y" ]; then
  cat gpgall.log
fi
rm ./gpgall.sh

文件多时,等待时间长,且要全部结束时才提示。

第二版,逐个文件提示

[root@FTPServer1 software]# cat gpg.sh
#!/bin/bash
log_file=gpgall.log

# clear file
[ -f ${log_file} ] && rm ${log_file}
[ -f tmp_file ] && rm tmp_file

echo "Begin verify asc......"
num=1
for asc_file in `ls *.asc`
do
        echo -e "\n${num}.\t${asc_file}"
        echo -e "\n${num}.\t${asc_file}" >>${log_file}
        gpg --verify ${asc_file} > tmp_file 2>tmp_file
        good_sign=`grep "Good signature" tmp_file | wc -l`
        cat tmp_file>>${log_file}
        if [ $good_sign == "1" ] ; then
                echo "Good signature!"
        else
                echo "Error! Bad signature!"
        fi
        ((num++))
done

echo -e "\nverify asc is done. "
echo "Please check ${log_file}, and make sure every file is Good signature!"

num_asc=`ls *.asc| wc -l`
num_good_sign=`grep "Good signature" ${log_file} | wc -l`
echo -e "\nTotal asc file is: ${num_asc}."
echo -e "Total Good signature is: ${num_good_sign}.\n"

echo -n "You can press y to check the File: "
read result
[ $result == "y" -o $result == "Y" ] &&  cat ${log_file}
rm ./tmp_file

abc目录有3个zip文件未下载,只下载了asc文件,可以正确识别

[root@FTPServer1 abc]# ./gpg.sh
Total asc file is: 39.
Total Good signature is: 36.

You can press y to check the File: n
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值