Modem with a sim card as an SMS provider

Question before use:
Is it possible to use a modem with a sim card as an SMS provider?
At the moment, we send SMS on critical events via gnokii, we have everything set up for this notification method.
But I can’t figure out if it’s possible in privacyIDEA.
Thank you

you can put your gnokii into a scipt.

Could you show an example of such a script?
We do it in one line:

echo “text” | gnokii --config /home/privacyidea/sms.conf --sendsms +9999999999999

There are no examples in the scripts folder and I don’t know how to wrap our string in a format that will be understood by privacyIDEA

“The script takes the phone number as the only parameter. The message is expected at stdin.”

Yes, I read it in the manual.
However, I’m not that good at programming, which is why I asked for an example script.
I can’t understand the logic, because I’ve never seen anything like this before.
Let’s say I make a simple script:

echo "/usr/bin/gnokii --config /home/privacyidea/sms.conf --sendsms "$number"

What variable should be used for phone number?
I searched on google, community forum, github for something that looks like a script to use as an example. I didn’t find anything, that’s why I wrote here.

I also tried this version of the script:

/usr/bin/sudo /usr/bin/gnokii --config /home/privacyidea/sms.conf --sendsms ${MOBILE_NUMBER}""

In theory, stdin should work here and it works if I try to run the script manually.
But it does not work from the privacyidea, although the log says that the message was successfully sent

[2023-04-27 12:19:43,046][761][139767662745152][INFO][privacyidea.lib.smsprovider.ScriptSMSProvider:78] Starting script '/etc/privacyidea/scripts/'.
[2023-04-27 12:19:43,059][761][139767662745152][INFO][privacyidea.lib.smsprovider.ScriptSMSProvider:95] SMS delivered to +99999999.

When I try to check through

Then I get the following message.
Unfortunately, I can’t figure out what exactly the error is - in the SMS sending script or I configured the policies incorrectly:

{"detail": {"attributes": {"state": null, "valid_until": "2023-04-27 12:35:48.870145"}, "client_mode": "interactive", "message": "Enter the OTP from the SMS:", "messages": ["Enter the OTP from the SMS:"], "multi_challenge": [{"attributes": {"state": null, "valid_until": "2023-04-27 12:35:48.870145"}, "client_mode": "interactive", "message": "Enter the OTP from the SMS:", "serial": "PISM0000B703", "transaction_id": "08230170624977015600", "type": "sms"}], "serial": "PISM0000B703", "threadid": 139767645959744, "transaction_id": "08230170624977015600", "transaction_ids": ["08230170624977015600"], "type": "sms", "preferred_client_mode": "interactive"}, "id": 2, "jsonrpc": "2.0", "result": {"authentication": "CHALLENGE", "status": true, "value": false}, "time": 1682598648.8860307, "version": "privacyIDEA 3.8.1", "versionnumber": "3.8.1", "signature": "rsa_sha256_pss:588520a76a7f5e12a9f784dbc287f6a70f6d7a163df9714aba2e13516de775f3f9ddeae9d254daf46415748d18060b3fe241b6b15034fa9f5101b32555a1a5cea9a2e48338c3d1beeac1cfb21500cb6e90e87bc345cb3dadc44718787358a327eb955e42625e0c3842b792eaa1d9b341bfefa5809961052e4936b8a1fcf45dcecb03d18af188e2f51123e1412ae269feb1142ac9476885b13fcb0da24692d07c84ca82f356c4ab5ffeb72fa6469f65ade65f776e6e8e023913b7b92059d5d46a7d3298b01627b6490e6e0a20acd03628ddc8fda381721bf62a80eda5a20d9254444bb25bf49435651d900fa029e8d4d114bd751b299e160b034719c756b8f478"}

For those who may face the same problem:
In my case, the privacyidea debug log showed everything correctly.
The script worked when manually launched from root and my user, but did not work when launched from under privacyidea.
It is also necessary to look at the Apache log.
According to it, it became clear that the privacyidea user did not have the rights to send to the device.
Silly mistake, but it was.

As for the script, the working version is really like this (I am attaching a piece)

/usr/bin/gnokii --config /home/privacyidea/sms.conf --sendsms ${MOBILE_NUMBER}

You can make it shorter, but I still have a send log in this script, so it’s implemented like this.

Thanks, the topic can be closed.

1 Like