PHP code example of edvnetwork / php-ssh

1. Go to this page and download the library: Download edvnetwork/php-ssh 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/ */

    

edvnetwork / php-ssh example snippets



  use EDV\net\ssh\SSHConnection;
  use EDV\net\ssh\auth\SSHPasswordAuthentication;

  $ssh = new SSHConnection();
  $ssh->open('127.0.0.1');
  $ssh->authenticate(
    new SSHPasswordAuthentication('user', 'password'));

  $directoryIterator = $ssh->getDirectoryIterator('/temp');

  while ($directoryIterator->valid()) {
    $splFileInfo = $directoryIterator->current();

    if ($splFileInfo->isFile()) {
        $splFileObject = $directoryIterator->openFile('r');
    }

    $directoryIterator->next();
}


  use EDV\net\ssh\SSHConnection;
  use EDV\net\ssh\auth\SSHPublicKeyAuthentication;

  $ssh = new SSHConnection();
  $ssh->open('example.com');
  $ssh->authenticate(new SSHPublicKeyAuthentication('user', '/home/user/.ssh/id_rsa.pub', '/home/user/.ssh/id_rsa', 'passphrase'));

  $directoryIterator = $ssh->getDirectoryIterator('/temp');

  while ($directoryIterator->valid()) {
    $splFileInfo = $directoryIterator->current();

    if ($splFileInfo->isFile()) {
        $splFileObject = $directoryIterator->openFile('r');
    }

    $directoryIterator->next();
}
json
""edvnetwork/php-ssh": "^2.1"
}

composer