Scenario:
When connecting to an SFTP server using SuiteScript 2.0, users may encounter an unexpected error. One of the reasons is because the directory property on the createConnection method does not exist on the server.
Solution:
To ensure that the problem is not the directory, remove the directory property on the connection or give it the root folder on the server (‘/’).
var connection = sftp.createConnection({
username: myusername,
passwordGuid: myPwdGuid,
url: testHost,
directory: '/',
hostKey: myHostKey
});