# Script: multipsk for OpenWrt 23+ snapshots

**URL:** <https://forum.gl-inet.com/t/script-multipsk-for-openwrt-23-snapshots/43766>\
**Category:** Router\
**Created:** [June 19, 2024, 1:05pm UTC](https://forum.gl-inet.com/t/script-multipsk-for-openwrt-23-snapshots/43766 "2024-06-19T13:05:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xize11](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/xize11/32/5340_2.png) [@xize11](https://forum.gl-inet.com/u/xize11)\
**Post date:** [June 19, 2024, 1:05pm UTC](https://forum.gl-inet.com/t/script-multipsk-for-openwrt-23-snapshots/43766/1 "2024-06-19T13:05:57Z")

</div>

Hey!,

Today I decided to write a script for multipsk also since OpenWrt doesn't have a luci option yet and I also liked the way of using it in a form of a batch command.

> **here it is**
>
> ```sh
> #!/bin/sh
> 
> while getopts k:i:v:r:h flag
> do
> case "${flag}" in
> k) key=${OPTARG};;
> i) interface=${OPTARG};;
> v) vid=${OPTARG};;
> r) radio=${OPTARG};;
> h)
> echo "makepsk: command help"
> echo "-k: wpa2 password"    
> echo "-i: interface/name where the vlan gets tagged to"
> echo "-v: the tagged vid"                              
> echo "-r: the defined radio"
> exit 1                      
> ;;    
> esac    
> done    
> 
> if [$OPTIND -eq 1]; 
> then
> echo "No options were passed."
> exit 1
> fi
> 
> echo "interface: $interface"
>                             
> uci add wireless wifi-station
> uci set wireless.@wifi-station[-1].vid="$vid"
> uci set wireless.@wifi-station[-1].iface="$radio"
> uci set wireless.@wifi-station[-1].key="$key"    
>                                              
> uci add wireless wifi-vlan
> uci set wireless.@wifi-vlan[-1].vid="$vid"
> uci set wireless.@wifi-vlan[-1].name="$interface"
> uci set wireless.@wifi-vlan[-1].network="$interface"
> uci set wireless.@wifi-vlan[-1].iface="$radio"      
>                                               
> uci commit wireless
> 
> ```

to make it executable use `chmod +x makepsk.sh`

a command looks like:  
`./makepsk.sh -k "yourpassword" -i "aya" -v "90" -r "default_radio1"`

this means clients with `yourpassword` gets redirected to interface `aya` the default\_radio1 is either 5ghz or 2.4ghz you can check this inside the wireless config in `/etc/config/wireless` you have to restart wifi manually with the `wifi` command.

I decided to make this since this creates 2 uci nodes each time which can be confusing + there isn't much documentation than maybe only about wpa\_psk\_file on the OpenWrt wiki, you need to use WPA2 otherwise it will not work.

there is a chance this doesn't work, then your OpenWrt version might be too old and you have to resort to wpa\_psk\_file, but this should work on the latest MT3000/MT6000 OpenWrt 24 snapshots, so I thought why not post it 😃

update 02-07-2024:

- add check against null arguments.

---

<div class="post-metadata">

**Author:** ![bruce](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/bruce/32/35649_2.png) [@bruce](https://forum.gl-inet.com/u/bruce)\
**Post date:** [October 29, 2025, 11:40am UTC](https://forum.gl-inet.com/t/script-multipsk-for-openwrt-23-snapshots/43766/2 "2025-10-29T11:40:01Z")

</div>


