I am currently in a project for which I created a function for uploading files using sFTP with the phpseclib library, I have tested the code from different media in the following way
localhost -> localhost = funciona.
localhost -> hostgator = funciona.
hostgator -> Otro Server = funciona.
hostgator -> Otro Server = funciona.
The problem is when I want to make a move inside a hostgator ie hostgator - > hostgator only that does not work in this way since it throws the following error:
Notice: Can not connect to $ server: 2222. Error 110. Connection timed out in /home3/tecmonay/public_html/system/lib/sftp/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php
require 'lib/sftp/vendor/autoload.php';
use phpseclib\Crypt\RSA;
use phpseclib\Net\SSH2;
use phpseclib\Net\SFTP;
$loader = new \Composer\Autoload\ClassLoader();
$loader->addPsr4('phpseclib\', __DIR__.'/phpseclib');
$loader->register();
$rsa = new RSA();
$sftp = new SFTP($server,'2222');
$rsa->loadKey(file_get_contents($pemFile));
if (!$sftp->login($user,$rsa)) {
exit('Login Failed');
}else{
var_dump($sftp->pwd());
}
I hope you can help me already thank you very much.