PHP Function SSH2_EXEC
The php function ssh2_exec allows you to run a command at the remote end of a ssh connection. It is especially useful for long running programs that may require a lot of time to finish.
When executed, ssh2_exec sends a message to the server asking the remote user to execute an action. The ssh2_exec call then waits until the command is finished and then returns a result or an error code.
To use ssh2_exec, you must first install the SSH2 extension. This can be done via your Distro's repositories or by building it from PECL (though that is not recommended).
Once you have the ssh2_exec function in your script, you can call many of the other ssh2 functions like ssh2_connect(), ssh2_auth_password(), ssh2_sftp_recv(), ssh2_scp_send(), etc.
ssh2_connect() - (void) - Attempts to connect to a remote SSH2 server. If an authentication method is not specified in the config, it will try to authenticate with either a plain password or public key. If the config specifies an agent, it will try to connect to a UNIX socket for ssh-agent-based user authentication or, for Windows users, will attempt to connect to pageant.
ssh2_config() - (int) Sets the configuration of libssh2. Currently supported values are: