hello Professionals, again having trouble connecti...
# integrations
a
hello Professionals, again having trouble connecting to an SFTP server. I get this error: Could not establish connection to Auth fail.
b
Have you confirmed that the credentials are valid?
a
yes, I have connected with an FTP client (Viper), and I can connect okay
b
What does the code look like
a
here is the function that does it
Copy code
function uploadFileToFTPServer(integrationId, fileObject, subFolder){
    //var INTEGRATION_ID = 'SM_OUT';
    try {
        var ftsRecordId = lookupFileTransferSetupRecordId(integrationId);
        var ftsRecord = record.load({type: 'customrecord_amp_file_transfer_setup', id: ftsRecordId, isDynamic: false});
        var myPwdGuid = ftsRecord.getValue('custrecord_amp_fts_password');
        var myHostKey = ftsRecord.getValue('custrecord_amp_fts_host_key');
        var serverUrl = ftsRecord.getValue('custrecord_amp_fts_server_url');
        var user = ftsRecord.getValue('custrecord_amp_fts_user_id');

        // establish connection to remote FTP server
        var connection = sftp.createConnection({
            username: user,
            passwordGuid: myPwdGuid,
            url: serverUrl,
            directory: ftsRecord.getValue('custrecord_amp_fts_server_path'),
            hostKey: myHostKey
        });
        log.debug('uploadFileTohFTPServer', 'connected');
        log.debug('filename', fileObject.name);
        log.debug('server path', ftsRecord.getValue('custrecord_amp_fts_server_path'));

        connection.upload({
            //directory: ftsRecord.getValue('custrecord_amp_fts_server_path'),
            directory: subFolder,
            file: fileObject,
            filename: fileObject.name,
            //filename: 'test.jpg',
            replaceExisting: true
        });

    } catch (e) {
        log.error('uploadFileTohFTPServer ERROR', e.message + ' - ' + e.stack);
    }
    return true;
}
b
What does the credentials field look like
a
sorry, what field?
b
The value for myPwdGuid should come from a credential field
a
7bc7a073ad9e443788964cf1513ea88d
that's the Password GUID
b
The guid itself is not usually the problem, its the configuration that goes into it from creating the credential field
a
okay... let me try again
I am using a tool script to do it
worked okay for other SFTP server
b
im going to be asking what are the parameters to Form.addCredentialField
and checking if they are correct
a
hmm, not working
but the credentials should be fine, I have generated them now several times
b
general things you get wrong are the url and hostkey
a
yeah... but I have tried several times
b
or any of the restrictions on the credential field
a
I do the same for a different server and works fine
b
assuming you arent doing anything like changing scripts, that generally leaves the
restrictToDomains
a
right... but I am changing that okay, same script
something related to this server Authentication...
b
or
url
it could be non standard ports
a
@battk I am still waiting on this. The port seems to be the standard one
I found this article in SuiteAnswers, and I have asked the SFTP admins to check
Scenario When establishing a connection to a server using the sftp.createConnection API, the user gets an error: _"_FTP_CANNOT_ESTABLISH_CONNECTION_"._ This means that the password/username was invalid or permission to access the directory was denied. Solution One possible solution is to enable password authentication for SSHD. The SSH server reads several configuration files. The sshd_config file specifies the locations of one or more host key files (mandatory) and the location of authorized_keys files for users. It may also refer to a number of other files. On the configuration file sshd_config, enable the following: 1.     /etc/ssd/sshd_config >>> PasswordAuthentication yes 2.     /etc/cloud/cloud.cfg >>> ssh_pwauth: 1 - This configuration ensures that the PasswordAuthentication setting is saved on each boot
that is the error that I get
b
probably want to check with netsuite support
ive exhausted what i can do without actual access to the credentials
a
yeah, thanks