> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/keeperpam/jp/commander-cli/command-reference/connection-commands/sftp-sync.md).

# SFTP同期

## 概要

Keeperボルトに保存されたクレデンシャルを使用すると、SFTPサーバーへの接続が容易になり、サーバーからマシン上の指定した場所へファイルが自動的にダウンロードされます。

SFTPクレデンシャルの保護、またはファイルのダウンロードやバックアップの自動化をコマンダーで行えます。

## ファイルを同期

コマンダーのSFTP同期を使用するには、`rsync` コマンドを使用します。

### 初回設定

SFTP同期を初めて実行するときは、プラグインのタイプ、リモートファイルへのパス、使用するクレデンシャルのレコードを指定する必要があります。

`--plugin` 使用するプラグインの種類 (SFTP)

`--remote-path` SFTPディレクトリ内でダウンロードするファイルへのパス

`--record` SFTPクレデンシャルを格納するレコードのUIDまたはパス

例:

{% code overflow="wrap" %}

```bash
rsync "path/to/files_location/" --plugin sftp --remote-path "/path/to/files" --record "credentials/SFTP creds"
```

{% endcode %}

これらのオプションを一度指定すると、設定が指定したレコードに保存されます。以降のSFTP同期では、ファイルのダウンロード先を指定するだけで実行できます。

```bash
rsync "path/to/files_location/"
```

## 同期の自動化

コマンダーは複数の方法で自動化できます。詳細は、[バッチモードのドキュメント](/keeperpam/jp/commander-cli/commander-installation-setup/logging-in.md#executing-commands-with-persistent-login)をご参照ください。このセクションでは、SFTP同期の自動化例を取り扱います。

### SFTP同期を繰り返し実行

コマンダー構成ファイルを編集すると、指定した頻度でコマンドを実行するように設定できます。

SFTP同期の初回設定後、指定した頻度で同期するように設定できます。

24時間に1回SFTPサーバーと同期するようにコマンダーを自動化するには、構成に以下のフィールドを追加します。

`"commands": ["rsync"],`

`"timedelay": 86400`

完全な構成ファイルの例:

{% code title="sync.conf" %}

```
{
    "server": "keepersecurity.eu",
    "user": "services@company.com",
    "private_key": "yaeK4jMeIGNkSR2[...]AA",
    "device_token": "g6RDMxr[...]z-xQ",
    "commands": ["rsync"],
    "timedelay": 86400
}
```

{% endcode %}

設定後、編集した構成ファイルを使用してコマンダーを実行し、自動化を開始します。コマンドライン/ターミナルから実行できます。

`$> keeper shell --config "/sync.conf"`

{% hint style="info" %}
構成ファイルにはその他のフィールドが含まれる場合があります。詳細は、[こちら](/keeperpam/jp/commander-cli/commander-installation-setup/configuration/configuration.md#commander-configuration-file)をご参照ください。

コマンダーは次回のコマンド実行まで実行を継続します。コマンダーが終了した場合やマシンの電源が切れた場合は、処理を続行するためにコマンダーを再起動する必要があります。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/commander-cli/command-reference/connection-commands/sftp-sync.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
