Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTP over TLS #55

Open
nomanmaqsood opened this issue Jul 11, 2017 · 10 comments
Open

FTP over TLS #55

nomanmaqsood opened this issue Jul 11, 2017 · 10 comments

Comments

@nomanmaqsood
Copy link

nomanmaqsood commented Jul 11, 2017

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
Copy link
Author

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 ?

@atinux
Copy link
Owner

atinux commented Jul 12, 2017

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

@nomanmaqsood
Copy link
Author

nomanmaqsood commented Jul 13, 2017

@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
Copy link
Author

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

@atinux
Copy link
Owner

atinux commented Jul 18, 2017

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.

@nomanmaqsood
Copy link
Author

tried this as well, but did not work

@atinux
Copy link
Owner

atinux commented Jul 19, 2017

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

@d0b1010r
Copy link

@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);

@kucherenkovova
Copy link

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

@communque
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants