> 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/secrets-manager/secrets-manager-command-line-interface/init-command.md).

# initコマンド

**説明:** ワンタイムアクセストークンを初期化します。

**パラメータ**

実行するサブコマンド

形式: **`ksm init <サブコマンド>`**

**サブコマンド**

| サブコマンド    | 説明                                     |
| --------- | -------------------------------------- |
| `default` | 引き換えられたトークンをbase64エンコードJSONとして返す       |
| `k8s`     | 引き換えられたトークンをKubernetesシークレットスクリプトとして返す |

{% hint style="warning" %}
`default` と `k8s` では、ワンタイムアクセストークンをコマンドライン引数として渡します (`ksm init default <TOKEN>`、`ksm init k8s <TOKEN>`)。環境変数で渡す方法はありません。トークンはシェル履歴に残り、Linuxの `ps aux` などプロセス一覧からも短い間見えます。1回限りのトークンなので、生成したらすぐに引き換え、信頼できる非公開のシェルで実行してください。
{% endhint %}

## **default**

ワンタイムアクセストークンを初期化し、Github ActionsやTerraformなどの外部統合で使用する設定プロファイルを作成します。設定の出力は、base64でエンコードされたJSON (デフォルト) またはk8s形式で生成できます。他のKSM開発者用SDKやアプリケーションは、この形式の設定を理解できます。

`ksm init default <トークン>`

オプションパラメータ

* `--plain` 設定をbase64でエンコードしません。プレーンなJSONを返します。
* `-h`, `--hostname` ホスト名を変更します。
* `--skip-ssl-verify` リモートSSL証明書を検証しません。

```
$ ksm init default XX:XXXX

ewogICAgImNsaWVudElkIjogInd ...U1R4eUQrU3ZNbkhrMTVLUHRGS2MrZlZJOGtlOUtL==
```

## k8s

ワンタイムアクセストークンを初期化して、Kubernetesシークレットスクリプトに設定します。

`ksm init k8s <トークン>`

オプションパラメータ

* `--name, -n` Kubernetesシークレットの名前。デフォルトは**ksm-config**です。使える文字は小文字、数字、`-`、`.` のみです。`.` で区切った各ラベルは、先頭と末尾を英字または数字にしてください。名前は253文字以内です (KubernetesがSecret名に適用するRFC 1123のサブドメイン規則)。無効な名前は、ワンタイムアクセストークンを引き換える前に拒否されます。
* `--namespace`, `--ns` Kubernetes名前空間の名前。デフォルトは**default**です。
* `--apply` 自動的にkubectlを使用してシークレットを適用します。シークレットのスクリプトは表示されません。
* `--immutable, -i` シークレットを改ざんできないようにします。Kubernetes 1.21以降が必要となります。
* `-h`, `--hostname` ホスト名を変更します。
* `--skip-ssl-verify` リモートSSL証明書を検証しません。

```
$ ksm init k8s XX:XXXX

apiVersion: v1
data:
  config: ewogICAgImNsaWVudElkIjogIml ... dWJsaWNLZXlJZCI6ICIxMCIKfQ==
kind: Secret
metadata:
  name: 'ksm-config'
  namespace: 'default'
type: Opaque
```

一部の名前はKubernetes Secretとして有効でも、YAML 1.1では曖昧です (例: `y`、`n`、`1e5`)。こうした名前も同様に引用符で囲まれるため、`kubectl apply` では真偽値や数値ではなく文字列として扱われます。


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/secrets-manager/secrets-manager-command-line-interface/init-command.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
