0
// Sample FTP Code
// ------------------
try {
    const Client = require('ssh2').Client;
    const conn = new Client();

    var ftpConfig = {
        host: 'ip',
        port: port,
        username: 'username',
        password: 'password'
        , readyTimeout: 5000
        
    }
    conn.on('ready', () => {
        console.log('Client :: ready');
        conn.sftp((err, sftp) => {
            if (err) throw err;
            sftp.readdir('foo', (err, list) => {
                if (err) throw err;
                console.dir(list);
                conn.end();
            });
        });
    }).connect(ftpConfig);

} catch (error) {
    console.log(error, '============ Catch Error ==============');
}

Error

level:"client-timeout"
message:"Timed out while waiting for handshake"
stack:"Error: Timed out while waiting for handshake at Timeout._onTimeout (C:\Users\rabeeshv\Desktop\Rabeessh\Samples\node_modules\ssh2\lib\client.js:993:23) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7)"

Rabeesh
  • 31
  • 9
  • no ... ssh and FTP are not the same protocols. You cannot use ssh to connect to ftp – Ahmed Masud Jul 13 '21 at 06:22
  • FTP? You mean SFTP, right? Because SFTP is based on SSH and FTP is not. https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol – Daan Jul 13 '21 at 06:26
  • Its Just FTP and not SFTP. Is there any npm which connects both FTP and SFTP server? – Rabeesh Jul 13 '21 at 07:08

0 Answers0