Monday, 7 October 2013

How to install SSH for PHP5

from time to time you may need to do SSH commands to other pi's.

you can achieve this via php :)

1) Install SSH for PHP - sudo apt-get install libssh2-1-dev libssh2-php

2)Check that is installed: php -m |grep ssh2

3: Restart apache: sudo service apache2 restart

Now for the PHP part

$connection = ssh2_connect('', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, '/usr/local/bin/php -i');

No comments:

Post a Comment



Donate Towards More Raspberry PI's for Projects