This adapter uses phpseclib to provide a SFTP adapter for Flysystem.
composer require league/flysystem-sftp
use League\Flysystem\Sftp\SftpAdapter;
use League\Flysystem\Filesystem;
$adapter = new SftpAdapter([
'host' => 'example.com',
'port' => 22,
'username' => 'username',
'password' => 'password',
'privateKey' => 'path/to/or/contents/of/privatekey',
'root' => '/path/to/root',
'timeout' => 10,
'agent' => true,
'directoryPerm' => 0755
]);
$filesystem = new Filesystem($adapter);