0

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?

Community
  • 1
  • 1
  • 3
    There is probably not running SSH server on that FTP host. SFTP is not FTP! Mind the missing S! – Jakuje Jan 01 '17 at 22:20
  • 1
    Can you login to that server using a command-line `sftp` from the same machine that runs the PHP code? Show us its log/output (with `sftp -v`)! – Martin Prikryl Jan 02 '17 at 07:38
  • @Jakuje same thing i have done for a transfer to another SFTP account, but it works for that account. Its not working for a particular SFTP account and it throwing the error like SFTP login failed – Anandharaman Buvaneswaran Jan 03 '17 at 20:42

1 Answers1

0

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

kurdtpage
  • 3,142
  • 1
  • 24
  • 24