sftp - 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 文件柜中。
解决方案
有几件事:
restrictToScriptIds : runtime.getCurrentScript().id,
restrictToCurrentUser :false,
不是 createConnection 签名的一部分。当您创建 Suitelet 来保管您的凭证时,应该已经使用了这些。
但是,主机密钥投诉可以通过使用 linux 机器中的 ssh-keyscan 来处理。
ssh-keyscan 59.165.215.45
应该使用服务器名称重播,然后是 ssh-rsa,然后是一个长的 base64 字符串。复制该字符串,使其以 myHostKey 结尾并将 hostKeyType 设置为 RSA。
推荐阅读
- server - Netty 中的 ReplayingDecoder 在每次迭代中读取 10240 字节
- python - 如何适合第一个标签matplolib python的第二个标签底部
- cmd - 无法从 cmd 在 Documents 中找到文件
- django - 大型数据集的 Graphene-python 性能问题
- javascript - 我无法序列化用户,我不明白发生了什么
- javascript - 使用 % 运算符而不是 if 语句重写代码
- android - 如何使用旧版 React Native 中的导航器
- swift - 当 Store 的对象更新时,自动触发 ViewModel ObservableObjects 中的 objectWillChange.send()
- javascript - 在javascript中调整图像大小
- javascript - Mongoose - 对嵌套数组中的所有元素都有效的条件