What's new

vpnbook auto update password

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

bilboSNB

Senior Member
In case anyone else finds this useful I am automatically updating the password for the vpnbook openvpn client which changes periodically.

In the custom configuration section of the openvpn client I have this line pointing to the username and password file:

Code:
auth-user-pass /opt/tmp/user.conf

Then in my wan start


Code:
curl -s "http://www.vpnbook.com" | grep -A 1 "Username: vpnbook" | tail -n 2| cut -f2 -d " " | cut -f1 -d '<' > /opt/tmp/user.conf
sleep 60
service start_vpnclient1

So now when the wan comes up the openvpn client starts with the current vpn username and password.

I was looking into running the script also with a pre-up parameter as well so if the client is started manually the password would be updated but I dont think that is supported.

I have added another option into the custom config

Code:
down /jffs/scripts/vpnbook.sh

which again runs:

Code:
curl -s "http://www.vpnbook.com" | grep -A 1 "Username: vpnbook" | tail -n 2| cut -f2 -d " " | cut -f1 -d '<' > /opt/tmp/user.conf

Am I right in thinking that if the connection drops due to a password change or for some other reason (not a complete wan fail) and I have the poll interval set the password will update and the client will attempt to reconnect with the new password or would it be best to add in a " service restart_vpnclient1" to that script. I presume the wan-start script would kick in again if I had a complete wan outage and it came back up.
 
Last edited:
Thanks for this great post. This makes vpnbook usable. After installing curl, I put the following text in /jffs/scripts/openvpn-event

#!/bin/sh
curl -s "http://www.vpnbook.com" | grep -A 1 "Username: vpnbook" | tail -n 1| cut -f2 -d " " | cut -f1 -d '<' > /tmp/mnt/yourusbname/yourusbfolder/vpnbook.txt
nvram set vpn_client1_password="$(cat /tmp/mnt/yourusbname/yourusbfolder/vpnbook.txt)"

No carriage return on the first two lines...
This is for client1, if you wanted to have the password for client2 change, you would add or change the nvram set command to vpn_client2_password

NOTE that to install curl you can use entware-
https://github.com/RMerl/asuswrt-merlin/wiki/Entware

And to install curl once entware is installed type-
opkg curl

I start the client with a batch file (windows) containing the text (need putty and change to your directory/passwords):
g:
cd putty
start putty.exe username@yourddnsoripaddress -pw yourpassword -m g:\putty\batch\OPENVPNSTART.txt

The file OPENVPNCLIENT.txt contains the text:
service stop_vpnclient1
/jffs/scripts/openvpn-event
service start_vpnclient1
 
Last edited by a moderator:
Doesnt' work for me
This command clears the file. the file appears empty, without any information.
 
VPNBook's website recently changed, the password is on a different page, which might explain why your script no longer works.

Quite frankly, if you need to use a VPN service so often, you should consider paying for a service, instead of finding workarounds to take advantage of free offers.
 
I had the same issue and have updated the script.

#!/bin/bash
curl -s "http://www.vpnbook.com/freevpn" | grep -A 0 Username: | tail -n 1 | cut -f2 -d " " | cut -f2 -d '<' | cut -f2 -d '>' > /etc/openvpn/auth.txt
curl -s "http://www.vpnbook.com/freevpn" | grep -A 0 Password: | tail -n 1 | cut -f2 -d " " | cut -f2 -d '<' | cut -f2 -d '>' >> /etc/openvpn/auth.txt

someone smarter than me could probably do it in one line, but it works. Cheers.
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top