What's new

Setting a random password for guest wifi

  • 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!

redvers

Regular Contributor
I was going to post this directly here, but I must have too many code tags so it wouldn't let me.

As such, I have posted on the wiki on how to do this :

Setting a random password for guest wifi

Enjoy!


edit : following comments on this thread, I have added a couple of alternate functions that provide different ways of creating a random password. getrandopenssl uses the openssl rand option, and getpasswdme uses curl to access the https://passwd.me api. These may require additional software to be installed over & above the default busy box installation.
 
Last edited:
Nice

Though I don't have such need for my guest wifi, it's an interesting application I haven't seen in a while. :)
 
Great!
I was allways looking for a self changing Password for guest network. Not sure If i need it on a daily bases but should be pretty easy to change that.
Thanks for this solution and easy HowTo.
 
I have a strange issue:

- when I run the script from WinSCP > Execute I get a password based on rpg-phrases.txt.

- when I run manually from Putty or via services-start I get a password based on date

I have a RT-N66U router with AsusMerlin build 376.45.

What is wrong?
 
You probably have the older version of the code; I tweaked it yesterday to avoid this issue... I used a local path reference to the phrases file, rather than a fully qualified path.

If you take the code from the wiki again, it should be fixed there. Alternatively find the 3 references to rpg-phrases.txt and precede it with the path i.e. Set them to :

/jffs/scripts/rpg-phrases.txt
 
After seeing this run a few times on the cron schedule, it's obvious that the use of the timestamp doesn't provide a great random number generator...

As such I have tweaked the script to use /dev/urandom instead of the date function!

Updated script is on the wiki link in the first post!
 
Testing and on my third try, with your rpg-phrases.txt
(try 1+2+4 worked, ((my guestwifi is disabled)))
Code:
admin@D-Link:/jffs/scripts# ./rpg-passgen.sh
./rpg-passgen.sh: line 45: arithmetic syntax error

Done.

result on try 3 without number "Today's Guest1 password is : alicecooper"

how come ??

edit: sorry, rt-ac68u 378.50_ta
 
Last edited:
I suspect my /Dev/urandom code isn't quite right... Without the od command available in busy box I'm trying to find another way to pull a random numeric value...
 
I'm using the following urandom command to create 64 character random passwords (upper case, lower case and numbers):

Code:
< /dev/urandom tr -dc A-Za-z0-9 | head -c64 | cut -c1-64

If you only want numbers, then the following command creates a random string of 10 numbers:

Code:
< /dev/urandom tr -dc 0-9 | head -c10 | cut -c1-10

Cheers,
M.
 
That's pretty much what I am using; I think the issue is actually in the subsequent command where that output is used to determine something else. I think I need to trim leading zeroes from the urandom result before using it in the printf
 
Password Generator

You could perhaps try using this web based API to generate the password?

curl "https://passwd.me/api/1.0/get_password.txt?type=rah=10&charset=LOWERCASEALPHANUMERIC&type=pronounceable"

More detail on the parameters here;

https://passwd.me/developer/
 
admin@router:/tmp/home/root# openssl rand 12 -base64
Cgm98z5LuP+ctcRk
admin@router:/tmp/home/root# openssl rand 12 -hex
d8d7636fc0cd980d4fc0c4f0

:?
 
it should be fixed there
o.png
 
I had updated the wiki with a tweaked script to now use cut to get the random number... but now back to using head -c 7 - this sometimes gives a null result, which is what was causes the issue. But the other methods I tried didn't work either... haven't really got time to try debugging this at the minute, so if anyone else is up to it, feel free :)

Will also look in to adding openssl or the passwd.me api as alternatives; however they wouldn't really work for my purposes as I want something I can actually say to my teenage daughter, rather than having to keep writing it down or spelling it out (and probably getting mixed up with Oh's and Zero's :))

edit: make sure you use the version with the following line - I had an incomplete update saved to the wiki that could result in the script taking 100% cpu and never finishing!

tr -cd 0-9 </dev/urandom | head -c 7
 
Last edited:
Following comments on this thread, I have added a couple of alternate functions that provide different ways of creating a random password. getrandopenssl uses the openssl rand option, and getpasswdme uses curl to access the https://passwd.me api. These may require additional software to be installed over & above the default busy box installation.

The updated script is now available on the wiki page :

Updated wiki page
 
Newbie question

I followed your good How-To and end up in the latest step I couldn't get run:

- started rpg-passgen.sh manualy worked fine. Got a new password via email and could log in guest network
- added install-start and services-start to /jffs/scripts (there was no one before)
- made all exectuable and checked it by ls -l (showed -rwxrwxrwx)
- reboot router and didn't get a new password

- Add "touch /tmp/000servicesstart" as mentioned in wiki to check if script started but no file created under tmp after reboot

Wiki said "Support for these scripts must also be enabled." but couldn't find anything under Administartion/System that looks like enable scripting.
(jffs is enabled, of course)

It's the first time I'm using jffs and scripting and I'm sure this question was asked several times but couldn't find any post regarding this topic. Sorry.

(running 376.49_5)
 
Wiki said "Support for these scripts must also be enabled." but couldn't find anything under Administartion/System that looks like enable scripting.
(jffs is enabled, of course)

Administration -> System -> Enable JFFS custom scripts and configs

This also needs to be set to Yes
 
I followed your good How-To and end up in the latest step I couldn't get run:

- started rpg-passgen.sh manualy worked fine. Got a new password via email and could log in guest network
- added install-start and services-start to /jffs/scripts (there was no one before)
- made all exectuable and checked it by ls -l (showed -rwxrwxrwx)
- reboot router and didn't get a new password

- Add "touch /tmp/000servicesstart" as mentioned in wiki to check if script started but no file created under tmp after reboot

Wiki said "Support for these scripts must also be enabled." but couldn't find anything under Administartion/System that looks like enable scripting.
(jffs is enabled, of course)

It's the first time I'm using jffs and scripting and I'm sure this question was asked several times but couldn't find any post regarding this topic. Sorry.

(running 376.49_5)

You won't find the 'Enable Scripts/Configs option' .....unless you upgrade to Firmware 378.50 as this was added to prevent a rogue script from preventing the router from starting correctly, but is implied with firmwares prior to 378.50.
 

Attachments

  • 2015-02-24_11-49-16.png
    2015-02-24_11-49-16.png
    15.9 KB · Views: 669
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

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