PHP code example of sevencoder / ssh-connect
1. Go to this page and download the library: Download sevencoder/ssh-connect library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sevencoder / ssh-connect example snippets
ndency
use SevenCoder\SecureShell\SSH;
//Instance
$connectionSSH = new SSH;
$host = '127.0.0.1';
$port = '2222';
//Connection
if(!$connectionSSH->connect($host, $port)) {
die('Conection Fail');
}
//Authentication with user && password
if($connectionSSH->authPassword('user','password')) {
die('Athentication Fail');
}
//Authentication with pair keys
if($connectionSSH->authPublicKeyFile('user', 'id_rsa.pub', 'id_rsa.pem')) {
die('Athentication Fail');
}
//Execute Comands
$stdIo = $connectionSSH->exec('ls -l', $stdErr);
echo "STDERR:\n".$stdErr;
echo "STDIO:\n".$stdIo;