さまざまなビジネスケースで、個人がカスタムのコードロジックで外部 SFTP サーバーに接続しなければならない場合があります。このナレッジ記事では、SSH キーを使用して SFTP サーバーに接続するプロセスについて説明します。
この記事は、SSH キーがすでに正しく生成されていて、ユーザーが使用できることを前提としています。
SSH キーを生成すると、次のようにペアで作成されます。
1.SSH サーバーにコピーされる公開キー。公開キーのコピーを持っていれば、誰でもデータを暗号化することができ、そのデータを読むことができるのは、対応する秘密鍵を持っている人だけです。SSH サーバーがユーザーから公開キーを受信してそのキーを信頼できるとみなすと、サーバーは authorized_keys ファイルで鍵を承認済みとしてマークします。このようなキーは認証済みキーと呼ばれます。
2.ユーザーに残っている (唯一の) 秘密鍵。この鍵を所有していることは、ユーザーの ID の証拠になります。サーバーの公開キーに対応する秘密鍵を所有しているユーザーのみが接続できます。
ユーザーは秘密鍵を .p12 形式に変換して、[Private Key and Certificates] (秘密鍵と証明書) の下にある Business Manager に保存する必要があります。
たとえば、test_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"); where "key_12" is the name of the .p12 key setup in the BM.
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.