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

61 views
Skip to first unread message

Carlos Rey-Moreno

unread,
May 22, 2014, 10:27:40 AM5/22/14
to village-telco-dev, Elektra
Hi all, 

I've been trying unsuccessfully to create an extension in the Mesh Potato 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.

Best,

carlos

--
Carlos Rey-Moreno
Research Assistant
Office 1.28
Department of Computer Science
University of the Western Cape
Private Bag X17 - Bellville, 7535
Cape Town - South Africa
Tel: +27 (0) 21 959 2562 Cel: +27 (0) 76 986 3633
Skype: carlos.reymoreno Twitter: Creym

Carlos Rey-Moreno

unread,
May 22, 2014, 12:57:10 PM5/22/14
to village-telco-dev, Elektra

Hi all, I have managed to solve it somehow, but the solution is far from elegant.
The ssh was not working because the remote host was not in kwon_host.  However, now ssh within the script executed by System() (executig the same command on the terminal works perfectly) only works when executing scripts on the remote server, but is unable to redirect to a local file the output of the commands.
The solution I have come up with is creating a script on the remote server with a "scp" to bring the required info back into the host, which as said is far from elegant and efficient. Any pointer on how to troubleshoot th above?
best
carlos

Paul Gardner-Stephen

unread,
May 22, 2014, 7:57:49 PM5/22/14
to village-...@googlegroups.com, Elektra
You could make a script on the mesh potato that has the ssh command in it that you call using System() in Asterisk.  That way at least the scp could be on the mesh potato, and not the other way around.  Probably also makes it easier to debug the whole thing, so that file redirection can work.  Are you using the -t option to ssh to control whether it tries to allocate a tty? This can cause issues when running from inside other things.

Paul.

Carlos Rey-Moreno

unread,
Jul 10, 2014, 2:07:25 AM7/10/14
to village-telco-dev
Hi Paul, sorry for the delay response. Thank you very much for your answer! I solved it by creating a root directory in tmp, where I copy the ssh keys, and then chaging the HOME environment variable to /tmp/root/ within the script. The solution was suggested in:

This link had the solution: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=87600&view=next&sid=ea488289c4194b14bcfd3be7ad9fe078

and this one the explanation, although the solution is simpler in the link above: http://www.suphammer.net/forum/viewtopic.php?f=2&t=512

Hope it helps,

carlos


--
You received this message because you are subscribed to the Google Groups "Village Telco Development Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to village-telco-...@googlegroups.com.
To post to this group, send email to village-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/village-telco-dev/a6dbfd84-d3f4-472a-9a5f-5eb9babb84a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages