In this version, some new features are added. The main feature added in this version is called renew port number function. Now it can not only renew password but also can renew the port number.
Tag Archives | bash
用BashScript脚本自动修改shadowsocks密码多端口版
上次写了一个单用户的脚本可以修改配置文件的密码并重启服务,这次在上次脚本的基础上做了些改进,对多用户版的配置文件进行修改。
用BashScript脚本自动修改shadowsocks密码
最近闲着无聊,了解了一下bash命令,写了一个自动修改shadowsocks密码的脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#!/bin/bash #================================================================ # Script for Shadowsocks Single User Password Renewing on Ubuntu/Debian # @author minirplus # Usage: ./ss-password-renew.sh # More info: https://blog.minirplus.com/5800/ #================================================================ # get old password old_password=$(grep password /etc/shadowsocks.json) password_index=$(expr index "$old_password" :) old_password=${old_password:password_index} old_password=${old_password%%,*} old_password=${old_password// /} old_password=${old_password:1:$((${#old_password}-2))} echo "your old password is $old_password" # generate new password new_password=$RANDOM echo "your new password is $new_password" # replace old password to new password echo "replace new password $new_password to the shadowsocks config file..." sed -i 's/'"$old_password"'/'"$new_password"'/g' /etc/shadowsocks.json # restart shadowsocks service echo "Restarting shadowsocks service..." /usr/local/bin/ssserver -c /etc/shadowsocks.json -d restart # All Done! echo "All Done!" echo "You can now use new password $new_password to login shadowsocks service now!" |
运行结果如下
1 2 3 4 5 6 7 8 9 10 |
root@vps:~# /usr/local/sbin/change-shadowsocks-password your old password is 28882 your new password is 20713 replace new password 20713 to the shadowsocks config file... Restarting shadowsocks service... INFO: loading config from /etc/shadowsocks.json 2016-02-15 17:17:33 INFO loading libcrypto from libcrypto.so.1.0.0 stopped started All Done! You will now can use new password 20713 to login shadowsocks service |
shadowsocks配置文件如下
1 2 3 4 5 6 7 8 9 10 |
{ "server":"0.0.0.0", "server_port":8381, "local_address": "127.0.0.1", "local_port":1080, "password":"20713", "timeout":300, "method":"aes-256-cfb", "fast_open": false } |