HELP: unlock/lock dataset from bash script

Hi,
for a few days I have installed Truenas Scale Community Edition 25.04 on my NAS Terramaster F4-424 Max. Then I created all my datasets. One of these is encrypted with a password. It will not have to contain important things, so the security level can also be minimal, just a simple password. Eventually I shared the datases (also the encrypted one) with samba.

Now I would like to manage the unlock and lock of the encrypted dataset, from the bash console I open through SSH. So I would like to create two bash scripts, one that unlock the dataset and the other that lock that dataset. Given the minimum safety required, the unlock script can also contain the password so as not to be requested to be manually inputed.

In this way an authorized user can connect to the NAS using ssh and execute the unlock script and then do what he owes. At the end of the operations, the same user can execute the other script that locks the dataset and finally disconnect from the NAS.

Can someone explain to me exactly which commands I need to execute and the exact syntax. On my previous NAS (Synology) I already did the same things, but TrueNAS is a new territory for me.

Thanks, best regards

I forgot to specify that the two scripts must reside in the NAS. For this reason they are performed after the user has connected with SSH.

Thanks again

I solved my problem with the help of @winnielinnie (Unlock dataset via SSH - #5 by lurgainn) and this web page:
Unlocking ZFS datasets on TrueNAS Scale with midclt

I write it only because maybe it will be able to serve someone else

Cheers