2017 © Pedro Peláez
 

library sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

image

idct/sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

  • Monday, June 4, 2018
  • by ideaconnect
  • Repository
  • 7 Watchers
  • 12 Stars
  • 15,052 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

idct-sftp-client

Library that provides wrapper methods around SSH2, SCP and SFTP to simplify file download/upload over SSH/SCP/SFTP., (*1)

warning

I am still thinking about unification of download / upload methods by passing a parameter which would define the connection type therefore method names may change., (*2)

installation

Depending on your project include the files directly or use autoloader., (*3)

Direct usage

Just include all the required files:, (*4)

include "/path/to/idct/sftp-client/src/AuthMode.php";
include "/path/to/idct/sftp-client/src/Credentials.php";
include "/path/to/idct/sftp-client/src/SftpClient.php";

Composer

Just execute:, (*5)

composer require idct/sftp-client

which will create vendor folder with idct/sftp-client. Then just include the autoloader:, (*6)

include "vendor/autoload.php";

usage

After you have installed the project import required classes in your project:, (*7)

use IDCT\Networking\Ssh\SftpClient;
use IDCT\Networking\Ssh\Credentials;

Initialize instance of the class:, (*8)

$client = new SftpClient();

Create authorization mode to your SFTP server:, (*9)

When you have username and password:

$credentials = Credentials::withPassword($username, $password);
$client->setCredentials($credentials);

When you have public key:

$credentials = Credentials::withPublicKey($username, $publicKey, $privateKey, $passphrase = null);
$client->setCredentials($credentials);

$publicKey and $privateKey are paths to respective files., (*10)

Connect to the server

$client->connect($host);

Downloading using SFTP:

$client->download(ENTER_REMOTE_FILE_NAME);
$client->download(ENTER_REMOTE_FILE_NAME, ENTER_LOCAL_FILE_NAME);

Uploading using SFTP:

$client->upload(ENTER_LOCAL_FILE_NAME);
$client->upload(ENTER_LOCAL_FILE_NAME, ENTER_REMOTE_FILE_NAME);

Downloading using SCP:

$client->scpDownload(ENTER_REMOTE_FILE_NAME);

Uploading using SCP:

$client->scpUpload(ENTER_LOCAL_FILE_NAME,ENTER_REMOTE_FILE_NAME);

Closing connection:

$client->close();

Remote prefix, local prefix

Prefixes set using methods: setRemotePrefix and setLocalPrefix allow to set common directories for storage. Please follow phpDoc of respective upload/download methods to know when, (*11)

contribution

If you find any issues or want to add new features please use the Issues or Pull Request functions: code addition is much appreciated!, (*12)

Before sending code be sure to run fix_code.sh to clean it up., (*13)

Thanks!, (*14)

The Versions

04/06 2018

dev-master

9999999-dev https://github.com/ideaconnect/idct-sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

  Sources   Download

MIT

The Requires

  • ext-ssh2 >=0.12
  • php >=5.4.0

 

The Development Requires

by Bartosz Pachołek

ssh sftp ssh2 scp idct

04/06 2018

0.4.2

0.4.2.0 https://github.com/ideaconnect/idct-sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-ssh2 >=0.12

 

The Development Requires

by Bartosz Pachołek

ssh sftp ssh2 scp idct

04/06 2018

0.4.1

0.4.1.0 https://github.com/ideaconnect/idct-sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-ssh2 >=0.12

 

The Development Requires

by Bartosz Pachołek

ssh sftp ssh2 scp idct

04/06 2018

0.4.0

0.4.0.0 https://github.com/ideaconnect/idct-sftp-client

Library that provides wrapper methods around SSH2 and SFTP to simplify file download/upload over SSH/SCP/SFTP.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-ssh2 >=0.12

 

The Development Requires

by Bartosz Pachołek

ssh sftp ssh2 scp idct