Unable to execute an order over ssh with System() app in ast

Hi all,

I’ve been trying unsuccessfully to create an extension in a router running OpenWRT for retrieving a value in a remote mysql database.
For that I have created a script that connects to the database and load the value in a temporary file and parse it. For connecting to the remote databse I use Public Key Authentication (PKA), so it doesn’t ask me the password when executing it.
The script works fine when I execute it in the command line of the mesh potato, however it does not work when executed by asterisk within a System() application. Asterisk provides little info as ${SYSTEMSTATUS} return success.
I have redirected sterr of the execution of the ssh to a file in order to see what is the problem and it looks like the PKA is not working, as it contains the typical dialog when establishing an unsecure ssh connection.
I don’t know how to continue troubleshooting as everything in the asterisk folder is owned by root, which is the user with the PKA credentials.
I hope someone can help me to shed some light.



Is the asterisk process owned by root ?

It generally isn’t.

I have also such problem.

Install freesshd on windows station. On asterisk system generate private and public key, copy private key to /home/asterisk/.ssh/ folder. chown asterisk,chgrp asterisk, chmod 600 on id_rsa. Public key cpy to windows station.

In root console command “ssh HOST -l asterisk -i /home/asterisk/.ssh/id_rsa calc” working fine but if I use this command for System() in extension.conf I can see execution of this command in verbose but it doesn`t work.

I think I do some simple mistake because I am newbie in Asterisk, but can someone help me?
I just want to have possibility to launch powershell script by asterisk on windows clients.

Seems to be an ownership/running user problem in both cases, as constantinp already said.

Check the running user with ‘ps aux | grep asterisk’

You may also try stopping Asterisk and starting with ‘asterisk -vvvvvvvgc’, so it will write everything to console from very start.

You may also add some piece of code to the script which will check the username or ID of a user (for example 0 for root) who runs the script.