node-ftps icon indicating copy to clipboard operation
node-ftps copied to clipboard

FTP over TLS

Open nomanmaqsood opened this issue 7 years ago • 10 comments

Hello,

I am trying to connect FTP server which is over tls,

but I am getting this error

null { error: 'ls: Fatal error: max-retries exceeded\n', data: '' }

Here is my code

var FTPS = require('ftps'); var ftps = new FTPS({ host: "", username: '', password: '*************', port: 990, protocol: 'sftp', sshKeyPath: "1.ssh" });

ftps.ls().exec(function (err, res) { if (err || res.error) return console.log('Error', (err || res.error)); console.log(res); });

ftps.addFile('test.text').exec(function (err, res) { if (err || res.error) return console.log('Error on adding file:', (err || res.error)); console.log('File added on server!'); });

Please guide me, the fault is in my code or on ftp server or in the library ? https://ibb.co/fibpAF

nomanmaqsood avatar Jul 11 '17 08:07 nomanmaqsood

Here is my code

var FTPS = require('ftps'); var ftps = new FTPS({ host: "", username: '', password: '*************', port: 990, protocol: 'sftp', sshKeyPath: "1.ssh" });

ftps.ls().exec(function (err, res) { if (err || res.error) return console.log('Error', (err || res.error)); console.log(res); });

ftps.addFile('test.text').exec(function (err, res) { if (err || res.error) return console.log('Error on adding file:', (err || res.error)); console.log('File added on server!'); });

Please guide me, the fault is in my code or on ftp server or in the library ?

nomanmaqsood avatar Jul 11 '17 12:07 nomanmaqsood

Can you try to use lftp command directly and see if you can connect? See https://stackoverflow.com/questions/23900071/how-do-i-get-lftp-to-use-ssl-tls-security-mechanism-from-the-command-line

atinux avatar Jul 12 '17 21:07 atinux

@Atinux I tried to connect using lftp from terminal, and it worked fine, here is the screenshot https://ibb.co/hf3Y5F.

I set the lftp to set ssl:verify-certificate no and it worked Now how to it with your library ?

nomanmaqsood avatar Jul 13 '17 06:07 nomanmaqsood

@Atinux Its been 3 days I have posted this problem.

nomanmaqsood avatar Jul 14 '17 11:07 nomanmaqsood

Hi @NomanMaqsood

I have been in holidays for the last 4 days, please remember I'm maintaining this project for free :)

Can you try to use the additionalLftpCommands property to add these specific commands?

additionalLftpCommands: 'set ssl:verify-certificate no; set ssl-allow true; set passive-mode yes'

Please take a look at https://github.com/Atinux/node-ftps/blob/master/index.js#L106 to understand more how it works.

atinux avatar Jul 18 '17 13:07 atinux

tried this as well, but did not work

nomanmaqsood avatar Jul 19 '17 05:07 nomanmaqsood

@NomanMaqsood do you mind sending me an email (look on my Github profile) with the details to connect to this specific server?

atinux avatar Jul 19 '17 08:07 atinux

@NomanMaqsood I just successfully connected to an ftp server over ssl:

var FTPS = require('ftps');
var ftps = new FTPS({
	host: 'xx',
	username: 'xx',
	password: 'xx',
	protocol: 'ftp', // <----- !
	port: 5021,
	additionalLftpCommands: [
		'set ssl-allow true',
		'set ssl:verify-certificate no',
		'set passive-mode yes'
	].join(';'),
});
ftps.ls().exec(console.log);

d0b1010r avatar Jul 20 '17 09:07 d0b1010r

var FTPS = require('ftps');
var ftps = new FTPS({
	host: 'xx',
	username: 'xx',
	password: 'xx',
	protocol: 'ftps',
	additionalLftpCommands: [
		'set ssl-allow true',
		'set ssl:verify-certificate no',
		'set passive-mode yes'
	].join(';'),
});
ftps.ls().exec(console.log);

worked for me

kucherenkovova avatar Dec 11 '17 13:12 kucherenkovova

So I'm able to connect using lftp in powershell, but not when using node ftps on Windows.

Here's the powershell version: lftp -u 'uid,pwd' -e 'set ftp:ssl-allow 0; ls /path/to/get;' -p 21 ftp.domain.com Works perfectly. Returns the file directory.

Here's the node version

var FTPS=require("ftps");
var Options={
	host: ftp.domain.com,
	username: "uid",
	password: "pwd",
	port: 21,
	escape: false,//or true  Tried both
	retries: 2,
	additionalLftpCommands: "set ftp:ssl-allow 0; ls /path/to/get"
};
var ftps = new FTPS(Options);
ftps.exec(function(Err,Rslts){
	if(Err){
		console.log(Err);
	}else{
		console.log(Rslts);
	}
});

Returns the error "ls: ls /path/to/get: not connected\n"

communque avatar Oct 08 '18 14:10 communque