Console
A very simple library to help working with ssh2 a bit cleaner.
Connecting to a server
The below code will demonstrate how to connect to a remote server either using basic auth or using ssh-* keys. If you want to connect using ssh keys they you will need to pass the location of the public and private ssh key.
$connection = new \Console\Connection('hostname', 'username', 'password');
This example will demonstrate how to connect using ssh keys. You will need to pass the hostname, username, public/private key location and if you have a password to encrypt the private ssh key then you will need to pass that as the 5th argument.
$connection = new \Console\Connection('hostname', 'username', '~/.ssh/id_rsa', '~/.ssh/id_rsa.pub');
Running commands
Once you have setup a connection instance, you can now run commands. The below code will show you how you can run commands on that connection instance.
$console = new \Console\Console($connection);
$output = $console
->run('whoami')
->output();