SSH Into Linux Server With a PHP Script

SSH Into Linux Server With a PHP Script

I had a need to allow a client to reboot there MySQL Database server from a PHP script. I tried using Server Bash scripts, PHP functions, and several other things which I cant recall at the moment. None of the things I tried ever really worked 100% though.

So today I cam across this great library PHP Secure Communications Library. It describes itself as a library with pure-PHP implementations of an arbitrary-precision integer arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael, AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509.

Half of thesse I have no idea what I wouyld ever use them for but the one that stands out is the SSH-2.

I was able to make a quick PHP script to allow my client to reboot his MySQL Database server within minutes. The code snippet is below:

You can find the library here: