PHP Function SSH2_Connect
php function ssh2_connect is an easy to use ssh connection class which handles establishing the SSH connection, verifying the server's host key and authenticating with password or public key. This class also supports sending commands to the server and reading their STDOUT for output and properly disconnecting.
The ssh2_connect() method accepts traditional URI login details, but can also reuse open connections if the caller passes the connection resource in the host portion of the URL (e.g. ssh2.connect('test@myserver')). The ssh2_connect() function also has optional argument(s) to specify an external program that should be invoked after the command is sent, which is useful for performing multiple commands over a single connection.
Options for the ssh2_connect() function include a comma separated list of encryption methods to advertise, an associative array of compression methods to advertise and an associative array of message authentication code (MAC) methods to advertise, each with a different preference order. Supported values are dependent on methods supported by the underlying libssh2 library. See >> libssh2 documentation for additional information.
To get ssh2_connect working on your system you need to install the php-ssh2 package from your Distro or PECL, which may require some configuration. Alternatively you can try to build ssh2 from source, but I find this very risky and recommend the ol7_developer_php72 repository instead, as it has been updated recently and it is stable. Having the latest version of libssh2 in your environment will ensure that all features are available, as well as bug fixes and security updates.