simple php ssh script does not display on browser
$var=`ssh 127.0.0.1 ls /`;
ssh promts me to enter my password
when i run script.php on bash it outputs but when i run it on my browser it does not output anything
please help how i can show the results on my browser
What are you trying to accomplish?
With the information provided I would say that when running from a console your script is being interpreted by bash (or other shell) and not php. Since your script is not proper php syntax it fails when run from the browser.
Here is how to run an external command from php.
Here is how to run a command via ssh.
FYI when posting code please use code tags to preserve formatting.
The Web server, and thus your PHP code, runs as a different UID than your own UID. The UID of the web server requires a password to login, if it's UID allows logins at all. Perhaps specify the username for whom you want the directory listing to be done.
PHP is a server side programming language. If you need to enter a password for SSH to work in the browser, then it is already too late because the PHP code has been executed. You'd need to put the password in the code somewhere (preferably in an include with read permissions to only apache or whatever web server you use and root) in order to log in.
|All times are GMT -5. The time now is 09:17 AM.|