#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
read -p “Please input the UserName you used for your shared VPN : ” vpnname
oldpass=`cat /etc/ppp/chap-secrets | grep $vpnname |awk ‘{print $3}’`
newpass=`openssl rand 6 -base64`
sed -i ‘s/’$oldpass’/’$newpass’/g’ /etc/ppp/chap-secrets
echo $newpass > /xxx/xxx/xxx.txt
这玩意运行之后屏幕中会出现Please input the UserName you used for your shared VPN 嗯,这句话的意思就是叫你输入哪个要改密码的vpn的用户名。然后运行完会将新密码写入一个叫xxx.txt的文件中,这个- -嗯,xxx你可以随便起名字。
另外还有一段php
<?php @$fp = fopen (“/xxx/xxx/xxx.txt”,’rb’);
if (!$fp){
echo “<p> 哦,密码还未设置!蛋疼的你慢慢联系管理员吧!
</p>”;
exit;
}
while (!feof($fp)){
$vpnpass=fgets($fp);
echo $vpnpass “<br />”;
}
?>
将这段php放到一个漂亮网页的某一个位置就能在那个位置显示密码了。嗯。鉴于php没测试。所以该威航仅发布在阿福个人博客。当然阿福会找时间修改shell脚本。争取做个选项来,看看有需要改多长时间的重复运行脚本。
未经允许不得转载:啊福主机 » 自动改VPN密码升级版