atinux / node-ftps

FTP, FTPS and SFTP client for node.js, mainly a lftp wrapper.
MIT License
203 stars 57 forks source link

How can I simply test the connection ? #58

Open omkartin opened 7 years ago

omkartin commented 7 years ago

Hey Atinux,

How would know that if there is a connection happened? I am using requireSSHKey: true and requirePassword:false

Please help me

hardy925 commented 6 years ago

This is not an issue, rather it is a how-to question and is probably better suited for stackoverflow or some other network.

This is an example script I have used

const FTPS = require('ftps');

const ftps = new FTPS({
    host: '<host>',
    username:  '<user>',
    password: '<password>',
    protocol: 'sftp',
    timeout: 3000,
    port: <port>,
    autoConfirm: true
});

ftps.raw('set sftp:auto-confirm on')
    .cd('.')
    .raw('nlist')
    .exec((err, res) => {
    if(err) {
    console.log(err);
    process.exit(1);
    } else {
        console.log(res);
        process.exit(0)
    }
});

Good luck.