I want to connect the SFTP in Magento 2
here is my code.
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$sftp = $objectManager->create('Magento\Framework\Filesystem\Io\Sftp');
$open = $sftp->open(array('host' => 'hostname','username' => 'username',
'password' => 'password',));
if ($open)
{
echo "true";
}
else
{
echo "false";
}
but does not work that code.