Site icon Web Niraj

Laravel 5.2: More SSH / SFTP Commands

Following on from my previous tutorial on writing code to access SSH / SFTP servers, I recently found that the SSH library from LaravelCollective uses was quite limited in what it allowed. However, by accessing the underlying libraries, you can extend the functionality available to you.

For instance, I wanted to get the list of files on a remote SFTP server, but the SSH Facade in Laravel didn’t have this functionality. Digging into the source code revealed that the phpseclib library was being used, which has  a lot more supported functions.

The underlying functions can be accessed using:

SSH::getGateway()->getConnection()->function($params);

Where function is a supported phpseclib function, and $params are any parameters needed for the function.

Examples

Here are just some of the extra functionality you can achieve using the phpseclib library:

See the gist on github.

Exit mobile version