I am trying to connect to Secured FTP server using package "ftp"
When i connect to not secured server code works fine and all events got raised without issues and i see a content.
But as long as i am trying to connect to server with acc and password, none of the event are getting raised and nothing in console logs (no errors), server just keep running.
I tried multiple ports, and 22 is correct one, because on other ports it error out on startup.
I tried secure: true/false
and it didn't helped me.
const Client = require("ftp");
const fs = require("fs");
let config = {
host: "10.2.22.22",
user: "test",
password: "pass",
port: 22
};
var c = new Client();
c.on("ready", function() {
c.list(function(err, list) {
if (err) throw err;
console.dir(list);
c.end();
});
});
c.on("greeting", function() {
console.log("greeting");
});
c.on("close", function() {
console.log("close");
});
c.on("end", function() {
console.log("end");
});
c.connect(config);
This is all console output which does not change:
Mac | util-> nodemon ftpUpload.js
[nodemon] 1.18.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ftpUpload.js`
After some timeout i noticed that
end
close
Got fired but nothing else. Does anyone knows where is the issue?
Port 22 is the default port for SSH. You can transfer files over SSH using the SFTP protocol.
SFTP is not the same as FTP (nor is it the same as FTPS (which is FTP + SSL or TLS).
You need to use a module that supports SFTP such as
ssh2
.