FTP node: No option to provide keyFile and passphrase [GOT CREATED]

FTP node should have options to support keyFile and passphrase as defined in https://www.npmjs.com/package/ssh2-sftp-client - which is a common use case for SFTP.

At least for SFTP, there should be an option to provide a keyFile and passphrase, either in the credentials or as additional options.

@frane this got added. Can you please test it locally and make sure it’s working as expected? Thanks.

@frane any update on this?

@RicardoE105 just now managed to test it.

It works well!

One thing: Passphrase should be masked like Password

Great, thanks a lot! We will make that change, merge and then release with the next version.

I’ve discovered one more thing. As I’m working with a very restrictive SFTP server, it doesn’t let me implicitly create directories.

Use case:

  1. set Operation to Upload
  2. set Path to /foo/bar.txt (where foo doesn’t exist yet)
  3. set random content (not important here)

If “foo” doesn’t exist, I’ll get the following error:

   ERROR: _mkdir: Permission denied /import/docs/x/
Error: _mkdir: Permission denied /import/docs/x/
    at Object.formatError (/Users/frane/workspace/n8n/node_modules/ssh2-sftp-client/src/utils.js:62:18)
    at /Users/frane/workspace/n8n/node_modules/ssh2-sftp-client/src/index.js:871:21
    at SFTPStream._transform (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/sftp.js:417:17)
    at SFTPStream.Transform._write (node:internal/streams/transform:184:23)
    at writeOrBuffer (node:internal/streams/writable:388:12)
    at SFTPStream.Writable.write (node:internal/streams/writable:333:10)
    at Channel.ondata (node:internal/streams/readable:715:22)
    at Channel.emit (node:events:327:20)
    at addChunk (node:internal/streams/readable:304:12)
    at readableAddChunk (node:internal/streams/readable:279:9)
    at Channel.Readable.push (node:internal/streams/readable:218:10)
    at SSH2Stream.<anonymous> (/Users/frane/workspace/n8n/node_modules/ssh2/lib/Channel.js:167:15)
    at SSH2Stream.emit (node:events:327:20)
    at parsePacket (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/ssh.js:3191:10)
    at SSH2Stream._transform (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/ssh.js:701:13)
    at SSH2Stream.Transform._write (node:internal/streams/transform:184:23)

If “foo” exists then everything runs fin and the upload performs as id should.

I think it would be greatly beneficial to export a couple of more common FTP operations, like “mkdir”, “rm” or “mv”.

In my case that would solve the issue as I’d be able to create the dir first and then upload the file to it.

This is quite weird as the node it’s supposed to do that for you (Create the folder in case it does not exist). Just tested and it’s working just fine for me.

All right… I’ve found the issue and fixed it here: SFTP: make dir creation more robust by frane · Pull Request #1166 · n8n-io/n8n · GitHub

It seems that the Windows-based SFTP that I have to work with is very sensitive. When calling mkdir there was always a trailing slash, e.g. /foo/bar/ which was rejected, but mkdir /foo/bar works.

2 Likes

Thanks a lot @frane! Just merged your PR. It will be released with the next version.

1 Like

Got released with [email protected]