首页 > 解决方案 > N/SFTP 模块中的 FTP_INCORRECT_HOST_KEY

问题描述

在使用 N/SFTP 模块创建从 NetSuite 到 SFTP 的连接时,我遇到了错误状态:

"FTP_INCORRECT_HOST_KEY","message":"提供的主机密钥与远程服务器的指纹不匹配。"

我曾尝试与我的服务器团队核实,但没有希望。任何人都可以建议我如何解决这个问题,或者我如何从服务器获取授权的指纹主机密钥。

我在下面提到的工具的帮助下尝试了 Suitescript 2.0 模块(N/SFTP)。

https://ursuscode.com/netsuite-tips/suitescript-2-0-sftp-tool/

/**
 *@NApiVersion 2.x
 @NScriptType ScheduledScript
 */
define(['N/sftp', 'N/file', 'N/runtime'],function(sftp, file,runtime) {  

    function execute(context)
    {
        var myPwdGuid = "Encrypted password by GUID";
        var myHostKey = "Some long Host key around 380 characters";

        // establish connection to remote FTP server
           var connection = sftp.createConnection({
            username: 'fuel_integration',
            passwordGuid: myPwdGuid, // references var myPwdGuid
            url: '59.165.215.45',//Example IP
            directory: '/sftproot/TaleoSync',
            restrictToScriptIds : runtime.getCurrentScript().id,
            restrictToCurrentUser :false,
            hostKey: myHostKey // references var myHostKey
           });
        // specify the file to upload using the N/file module

        // download the file from the remote server

        var downloadedFile = connection.download({
            directory: '/sftproot/TaleoSync',
            filename: 'Fuel Funnel Report_without filter.csv'
        });
        downloadedFile.folder = ;
        downloadedFile.save();

         context.response.write(' Downloaded "Fuel Funnel Report_without filter" to fileCabinet');

    }

    return {
        execute: execute
        };


});

我希望在 SFTP 和 NetSuite 之间建立连接,以从 SFTP 下载文件并将其放置到 NetSuite 文件柜中。

标签: sftpnetsuite

解决方案


有几件事:

restrictToScriptIds : runtime.getCurrentScript().id,
restrictToCurrentUser :false,

不是 createConnection 签名的一部分。当您创建 Suitelet 来保管您的凭证时,应该已经使用了这些。

但是,主机密钥投诉可以通过使用 linux 机器中的 ssh-keyscan 来处理。

ssh-keyscan  59.165.215.45

应该使用服务器名称重播,然后是 ssh-rsa,然后是一个长的 base64 字符串。复制该字符串,使其以 myHostKey 结尾并将 hostKeyType 设置为 RSA。


推荐阅读