在各种商业案例中,个人可能需要在自定义代码逻辑中连接到外部 SFTP 服务器。此 Knowledge 文章介绍了使用 SSH 密钥连接到 SFTP 服务器的流程。
本文假设已经正确生成 SSH 密钥,并且可供用户使用。
在您生成 SSH 密钥时,将成对创建密钥:
1.复制到 SSH 服务器的公钥。任何拥有公钥副本的人员都可以加密数据,而只有持有相应私钥的人员才能读取该数据。只要 SSH 服务器收到用户发送的公钥并认为该密钥可信,服务器会在其 authorized_keys 文件中将密钥标记为授权。此类密钥称为授权密钥。
2.用户保留(唯一)的私钥。此密钥的所有权是用户身份的证明。仅一位用户持有与服务器上的公钥对应的私钥
用户需要将私钥转换为 .p12 格式,并将其存储在 Business Manager 的“私钥和证书”下。
例如,下面说明了如何封装名为 testing_id_rsa 的私钥:
==========================================================================================
>>openssl req -new -days 3650 -key testing_id_rsa -out testing_id_rsa.csr
>>openssl x509 -days 3650 -signkey testing_id_rsa -req -in testing_id_rsa.csr -out testing_id_rsa.cer
>>openssl pkcs12 -export -out testing_id_rsa.p12 -inkey testing_id_rsa -in testing_id_rsa.cer -certfile testing_id_rsa.cer
==========================================================================================
将 SSH 密钥转换为 .p12 格式后:
1.登录 Business Manager
2.在“管理”下,选择“操作”
3.在“操作”中,选择“私钥和证书”
4.上传密钥(仅支持 .p12 格式)
5.上传密钥后,请使用以下代码指代密钥:
var keyRef = new keyRef("key_p12");其中,“key_12”是 BM 中 .p12 密钥设置的名称。
要连接到 SFTP 服务器,您可以使用 setIdentity 方法:
public void setIdentity( dw.crypto.KeyRef keyRef );
000395051

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.