I’m encountering an issue while trying to connect ...
# suitescript
b
I’m encountering an issue while trying to connect to an SFTP server. The error message I’m receiving states: ‘Could not establish connection to No more authentication methods available.’ This seems to be preventing me from establishing a connection. I would appreciate any advice or guidance on how to resolve this issue and successfully establish a connection with the SFTP server.
Copy code
FTP_CANNOT_ESTABLISH_CONNECTION
Copy code
{
   type: "error.SuiteScriptError",
   name: "FTP_CANNOT_ESTABLISH_CONNECTION",
   message: "Could not establish connection to No more authentication methods available.",
   id: "",
   stack: [
      "Error\n    at Object.execute (/SuiteScripts/SDB-TR-INIT-CONNECT-SFPT.js:25:38)"
   ],
   cause: {
      type: "internal error",
      code: "FTP_CANNOT_ESTABLISH_CONNECTION",
      details: "Could not establish connection to No more authentication methods available.",
      userEvent: null,
      stackTrace: [
         "Error\n    at Object.execute (/SuiteScripts/SDB-TR-INIT-CONNECT-SFPT.js:25:38)"
      ],
      notifyOff: false
   },
   notifyOff: false,
   userFacing: true
}
c
Something went wrong with authentication Can you share your code?
b
Copy code
const execute = (scriptContext) => {
            const scriptObj = runtime.getCurrentScript();
            // let connection = GetSFTPConnection(scriptObj);

            var username ='test-dev';
            var url = 'test-test';
            var hostKey = 'AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBELYopkHc6vi++AqprGSo00zclDui4Ywj08QrnZgkLOF9v8PX8nlNErFMpnq9XyDGhYTKcWK/NtmeHYJIeQ89XM=';
            var passwordGuid = '7c7ad4b42ef8482db8e7febb9aaf815e';
            var directory = '/';
            var port = 22;

           var objConnextion =  sftp.createConnection({
                username: username,
                passwordGuid: passwordGuid,
                url: url,
                directory: directory,
                hostKey: hostKey,
                port: port,
            });
            log.debug('objConnextion', objConnextion);
            // if (!connection) return [];
            // let listFiles = connection.list({
            //     path: "",
            //     sort: sftp.Sort.DATE_DESC,
            // });

        }
the url and user name are modifed but are info confiedent
c
I remember having alot of trouble with the whole password GUID thing, I honestly gave up on it and took the API Secrets route. You can save the password under Setup > Company > API Secrets, and then reference that secret by it's internalid in the script: let connection = sftp.createConnection({ username: 'test_sftp_user_12345', secret: 'custsecret_files_password', url: 'test.files.com', hostKey: creds.hostKeys["files.com"] });
b
Do I need to upload a correct file?
Why is it not giving me the option?
c
You shouldn't have to add a file, no. Be sure to set the restrictions as well. If I remember correctly, they'll block access to the secret by default until you open it up.
battk pointed out an important issue too - compatibility. NetSuite's a little picky about sftp server compatibility.
b
I am really very grateful
🙌 1
c
hey @Corey Schwoebel, I have used the below approach but it's throwing an error A problem occured whilst: <br>FTP_CANNOT_ESTABLISH_CONNECTION</br>Could not establish connection to No more authentication methods available.
let connection = sftp.createConnection({
username: 'test_sftp_user_12345',
secret: 'custsecret_files_password',
url: '<http://test.files.com|test.files.com>',
hostKey: creds.hostKeys["<http://files.com|files.com>"]
});
But when I try to hardcode the passwordGUID and its working correctly but I dont want to hardcode it in the code instead im planning to use secret management
b
Are you creating the key correctly through API Secret?
456 Views