I'm trying to retrieve the contents of a file on a remote server via SSH and display the results in a browser. The remote server's name and address is configured on my local server with the name "router", such that from the command line I can execute the following to successfully retrieve the results:
ssh router "cat /var/log/messages"
I'm having trouble getting this to execute in PHP - I can't get the quotes escaped properly. Here's my PHP script
<pre>
$command = 'ssh router \"cat /var/log/messages\"';
<?php system($command); ?>
</pre>
But this outputs the command string to the webpage instead of executing the command and returning the results.