Skip to content

Instantly share code, notes, and snippets.

@koreapyj
Created February 24, 2025 15:27
Show Gist options
  • Save koreapyj/72b9651225a9c4757e4b7efaf174e20d to your computer and use it in GitHub Desktop.
Save koreapyj/72b9651225a9c4757e4b7efaf174e20d to your computer and use it in GitHub Desktop.
OpenVPN user pass auth script for OpenWRT ubus
#!/bin/sh
. /usr/share/libubox/jshn.sh
userpass=`cat $1`
username=`echo $userpass | awk '{print $1}'`
password=`echo $userpass | awk '{print $2}'`
json_init
json_add_string "username" "$username"
json_add_string "password" "$password"
json_add_int "timeout" "1"
json_close_object
JSON=`json_dump`
if ubus call session login "$JSON"; then
exit 0
fi
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment