---
schema_version: "1"
id: 2c3d58df8161b6eadae6aba109688af8137d0b34d6809f193e5d7578de479946
title: SFTP サーバーへの接続の例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/sftp-connector/1.6/sftp-connection.md
canonical_url: https://docs.mulesoft.com/jp/sftp-connector/1.6/sftp-connection
source_site: docs.mulesoft.com
content_type: documentation
content_hash: bdd892470f8c65cf5bd53a8b7798427cb96a6b86bb2efd7fa391aeee01db33a3
description: MuleSoft Documentation Site
release: "1.6"
latest: false
---
# SFTP サーバーへの接続の例

次の例は、以下の作業を行うための SFTP 用 Anypoint Connector (SFTP Connector) グローバル設定要素の設定方法を示しています。

- [SFTP サーバーに接続する](#connect-sftp-server)
- [プロキシを介して SFTP サーバーに接続する](#connect-sftp-server-proxy)
- [SFTP サーバーに接続するための公開キーを設定する](#configure-public-key)

## [](#connect-sftp-server)SFTP サーバーに接続する

SFTP サーバーに接続するようにグローバル要素を設定する手順は、次のとおりです。

1. Studio キャンバスでコネクタの名前を選択します。
2. Studio キャンバスで操作を選択します。
3. 操作の設定画面で、​**\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックし、グローバル要素設定項目にアクセスします。
4. **\[General (一般)\]**​ タブで、コネクタの接続情報を指定します。
5. **\[Working Directory (作業ディレクトリ)\]**​ 項目を ​`${workingDir}`​ に設定します。  
    これは、このコネクタで使用するすべての相対パスのルートです。指定しない場合、デフォルト値はリモートサーバーになります。
6. **\[Host (ホスト)\]**​ 項目を設定して、SFTP サーバーホスト (​`localhost`​ や ​`192.168.0.1`​ など) を指定します。
7. **\[Port (ポート)\]**​ 項目を ​`${sftpPort}`​ に設定します。
8. **\[Username (ユーザー名)\]**​ 項目を ​`anonymous`​、​**\[Password (パスワード)\]**​ 項目を ​`password`​ に設定します。
9. **\[Advanced (詳細)\]**​ タブで、必要に応じてタイムアウト設定と再接続戦略を指定します。
10. **\[Test Connection (接続をテスト)\]**​ をクリックして、Mule が指定されたサーバーに接続できることを確認します。
11. **\[OK\]**​ をクリックします。

![SFTP Connector の \[Global Element Configuration (グローバル要素設定)\]](_images/sftp-global-configuration.png)

設定 XML エディターでは、​`sftp:config`​ の設定は次のように記述されます。

```xml
<sftp:config name="sftp">
  <sftp:connection username="anonymous" password="password"
    host="localhost" port="${sftpPort}"
    workingDir="${workingDir}"/>
</sftp:config>
```

## [](#connect-sftp-server-proxy)プロキシを介して SFTP サーバーに接続する

プロキシを介して SFTP サーバーに接続するようにグローバル要素を設定する手順は、次のとおりです。

1. Studio キャンバスでコネクタの名前を選択します。
2. Studio キャンバスで操作を選択します。
3. 操作の設定画面で、​**\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックし、グローバル要素設定項目にアクセスします。
4. **\[General (一般)\]**​ タブで、コネクタの接続情報を指定します。
5. **\[Working Directory (作業ディレクトリ)\]**​ 項目を ​`${workingDir}`​ に設定します。  
    これは、このコネクタで使用するすべての相対パスのルートです。指定しない場合、デフォルト値はリモートサーバーになります。
6. **\[Host (ホスト)\]**​ 項目を ​`127.0.0.100`​ に設定します。
7. **\[Port (ポート)\]**​ 項目を ​`${SFTP_PORT}`​ に設定します。
8. **\[Username (ユーザー名)\]**​ 項目を ​`muletest1`​、​**\[Password (パスワード)\]**​ 項目を ​`password`​ に設定します。
9. **\[Sftp proxy config (SFTP プロキシ設定)\]**​ 項目で、​**\[Edit inline (インライン編集)\]**​ を選択し、次の項目を設定します。
    
    - **Host (ホスト)**​: `localhost`
    - **Port (ポート)**​: `${proxyPort}`
    - **Protocol (プロトコル)**​: `HTTP`  
        プロトコルには、​`HTTP`​、​`SOCKS4`​、または ​`SOCKS5`​ を使用できます。
10. **\[Advanced (詳細)\]**​ タブで、必要に応じてタイムアウト設定と再接続戦略を指定します。
11. **\[Test Connection (接続をテスト)\]**​ をクリックして、Mule が指定されたサーバーに接続できることを確認します。
12. **\[OK\]**​ をクリックします。

![SFTP Connector の \[Global Element Configuration (グローバル要素設定)\]](_images/sftp-global-configuration-proxy.png)

**\[Configuration XML (設定 XML)\]**​ エディターでは、​`sftp:config`​ の設定は次のように記述されます。

```xml
<sftp:config name="sftp">
  <sftp:connection username="muletest1" password="password"
    host="127.0.0.100" port="${SFTP_PORT}" workingDir="${workingDir}">
      <sftp:sftp-proxy-config host="localhost" port="${proxyPort}" protocol="HTTP"/>
  </ftp:sftp-connection>
</ftp:config>
```

## [](#configure-public-key)SFTP サーバーに接続するための公開キーを設定する

次の例は、SFTP 設定の優先する認証方法として公開キーを設定する方法を示しています。この例では、PEM (Privacy Enhanced Mail) 形式の証明書を使用します。

1. Studio で、​**\[Global Elements (グローバル要素)\]**​ タブに移動します。
2. **\[Create (作成)\]**​ をクリックします。
3. `sftp`​ を検索します。
4. **\[SFTP Config (AQMP 設定)\]**​ を選択します。
5. **\[OK\]**​ をクリックします。
6. \[Global Element Properties (グローバル要素のプロパティ)\] ウィンドウで、​**\[Preferred authentication methods (優先する認証方法)\]**​ を ​**\[Edit inline (インライン編集)\]**​ に設定します。
7. プラス記号をクリックして、新しい値を追加します。
8. **\[Preferred authentication method (優先する認証方法)\]**​ ウィンドウで ​**\[Value (値)\]**​ を ​`PUBLIC_KEY`​ に設定します。
9. プラス記号をクリックして、新しい値を追加します。
10. **\[Value (値)\]**​ を ​`PASSWORD`​ に設定します。
11. **\[Host (ホスト)\]**​ を ​`sftp.host.com`​ に設定します。
12. **\[Port (ポート)\]**​ を ​`22`​ に設定します。
13. **\[Username (ユーザー名)\]**​ を ​`sftp ユーザー名`​に設定します。
14. **\[Password (パスワード)\]**​ を ​`sftp パスワード`​に設定します。
15. **\[Identity file (ID ファイル)\]**​ を PEM の場所のフォルダー ​`(Sftp-test-connection/src-main/resources/private.pem など)`​ に設定します。
16. **\[Passphrase (パスフレーズ)\]**​ を ID ファイルのパスワードに設定します。
17. **\[OK\]**​ をクリックします。

![SFTP Connector の公開キーの \[Global Element Configuration (グローバル要素設定)\]](_images/sftp-global-configuration-key.png)

**設定 XML**​ エディターでは、設定は次のように記述されます。

```xml
<sftp:config name="SFTP_Config" doc:name="SFTP Config" >
		<sftp:connection host="sftp.host.com" username="sftp username" password="sftp password" identityFile="Sftp-test-connection/src-main/resources/private.pem" passphrase="passwordfile" >
			<sftp:preferred-authentication-methods >
				<sftp:preferred-authentication-method value="PUBLIC_KEY" />
				<sftp:preferred-authentication-method value="PASSWORD" />
			</sftp:preferred-authentication-methods>
		</sftp:connection>
	</sftp:config>
```

## [](#関連情報)関連情報

- [SFTP Connector の例](https://docs.mulesoft.com/jp/sftp-connector/1.6/sftp-examples)
- [MuleSoft ヘルプセンター](https://help.mulesoft.com)