cannot connect to ftp.*****.com:22 with phpseclib

I am new to phpseclib and I am facing the same issue as this old Stack Overflow post.

<?php
set_include_path('/home/eibahhxo/public_html/EibaMed/phpseclib');
//echo get_include_path();
ini_set('display_errors', 'On'); ini_set('html_errors', 0); error_reporting(-1);
include(get_include_path().'/Net/SFTP.php');

$sftp = new Net_SFTP('ftp.*****.com',22);
if (!$sftp->login('username', 'password')) { //if you can't log on...
print_r($sftp->getSFTPErrors());
   exit('sftp Login Failed');
}

$output = $sftp->put('/inbound/00017', '/00017');
?>

While making this code, it throws this following error

Notice: Cannot connect to ftp.*****.com:22. Error 110. Connection timed out in /home/eibahhxo/public_html/EibaMed/phpseclib/Net/SSH2.php on line 1046 Array ( ) sftp Login Failed

How can I resolve this?

Upvotes: 0

Views: 3249

Answers (1)

kurdtpage
kurdtpage

Reputation: 3221

First, make sure the service is actually running with no errors. Check the error log

Second, check that your SFTP server is listening on port 22 (look for LISTEN or LISTENING):
netstat -na | find ":22" (on linux, use grep instead of find)

Third, check your firewall is not blocking port 22. Depending on your setup, you may have to check both the server firewall and the router or VPN firewall

Upvotes: 0

Related Questions